#define NULL ((void *)0)
typedef unsigned long size_t; // Customize by platform.
typedef long intptr_t;
typedef unsigned long uintptr_t;
typedef long scalar_t__; // Either arithmetic or pointer type.
/* By default, we understand bool (as a convenience). */
typedef int bool;
#define false 0
#define true 1

/* Forward declarations */

/* Type definitions */

/* Variables and functions */
int /*<<< orphan*/ close(int);
scalar_t__ connectToServer(int *, int);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ remoteGCD(int, unsigned int, unsigned int, unsigned int *);
int /*<<< orphan*/ remoteLCM(int, unsigned int, unsigned int, unsigned int *);
int /*<<< orphan*/ sprintf(char *, char *, char *, int);
int /*<<< orphan*/ sscanf(char *, char *, ...);
int /*<<< orphan*/ stdin;
int main(int argc, char *argv[]) {
  char str01[32], str02[32];
  unsigned int n1, n2, result01, result02;
  int sock, port;
  sscanf(argv[1], "%d", &port);
  if (connectToServer(&sock, port) != 0) {
    sprintf(str01, "I couldn't connect to %s:%d\n", argv[1], port);
    perror(str01);
    return -1;
  }
  printf("give me a natural number: ");
  fgets(str01, 32, stdin);
  sscanf(str01, "%u", &n1);
  printf("give me a natural number: ");
  fgets(str02, 32, stdin);
  sscanf(str02, "%u", &n2);
  remoteGCD(sock, n1, n2, &result01);
  printf("gcd(%u,%u)=%u\n", n1, n2, result01);
  remoteLCM(sock, n1, n2, &result02);
  printf("lcm(%u,%u)=%u\n", n1, n2, result02);
  close(sock);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe4b(%rip),%rsi
lea    -0x68(%rbp),%rdx
mov    $0x0,%al
call   1090 <sscanf@plt>
mov    -0x68(%rbp),%esi
lea    -0x64(%rbp),%rdi
call   1060 <connectToServer@plt>
cmp    $0x0,%rax
je     1206 <main+0x76>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x68(%rbp),%ecx
lea    0xe17(%rip),%rsi
call   10b0 <sprintf@plt>
lea    -0x30(%rbp),%rdi
call   10a0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    12dd <main+0x14d>
lea    0xe13(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    0x2dc9(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1070 <fgets@plt>
lea    -0x30(%rbp),%rdi
lea    0xe05(%rip),%rsi
lea    -0x54(%rbp),%rdx
mov    $0x0,%al
call   1090 <sscanf@plt>
lea    0xdd8(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    0x2d8e(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1070 <fgets@plt>
lea    -0x50(%rbp),%rdi
lea    0xdca(%rip),%rsi
lea    -0x58(%rbp),%rdx
mov    $0x0,%al
call   1090 <sscanf@plt>
mov    -0x64(%rbp),%edi
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
lea    -0x5c(%rbp),%rcx
call   1030 <remoteGCD@plt>
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
mov    -0x5c(%rbp),%ecx
lea    0xda0(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x64(%rbp),%edi
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
lea    -0x60(%rbp),%rcx
call   1080 <remoteLCM@plt>
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
mov    -0x60(%rbp),%ecx
lea    0xd86(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x64(%rbp),%edi
call   1050 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x60,%rsp
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe56(%rip),%rsi
xor    %r14d,%r14d
lea    0x14(%rsp),%rdx
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    0x14(%rsp),%esi
lea    0x10(%rsp),%rdi
call   1060 <connectToServer@plt>
test   %rax,%rax
jne    12c2 <main+0x132>
lea    0xe49(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e00(%rip),%r12
mov    (%r12),%edx
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   1070 <fgets@plt>
lea    0xe36(%rip),%rbx
lea    0xc(%rsp),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    (%r12),%edx
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   1070 <fgets@plt>
lea    0x8(%rsp),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1090 <sscanf@plt>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0x1c(%rsp),%rcx
call   1030 <remoteGCD@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0x1c(%rsp),%ecx
lea    0xdcc(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0x18(%rsp),%rcx
call   1080 <remoteLCM@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0x18(%rsp),%ecx
lea    0xdab(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x10(%rsp),%edi
call   1050 <close@plt>
mov    %r14d,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x8(%rbx),%rdx
mov    0x14(%rsp),%ecx
lea    0xd32(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   10b0 <sprintf@plt>
mov    %rbx,%rdi
call   10a0 <perror@plt>
mov    $0xffffffff,%r14d
jmp    12b2 <main+0x122>

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [29 x i8] c"I couldn't connect to %s:%d\0A\00"
@.str.2 = [27 x i8] c"give me a natural number: \00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%u\00"
@.str.4 = [15 x i8] c"gcd(%u,%u)=%u\0A\00"
@.str.5 = [15 x i8] c"lcm(%u,%u)=%u\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [32 x i8]
%7 = alloca [32 x i8]
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
%13 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 (i8*, i8*, ...) @sscanf(i8* %16, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%18 = load i32, i32* %13
%19 = call i64 @connectToServer(i32* %12, i32 %18)
%20 = icmp ne i64 %19, 0
br i1 %20, label %21, label %30
21: ; preds = %2
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 1
%25 = load i8*, i8** %24
%26 = load i32, i32* %13
%27 = call i32 @sprintf(i8* %22, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %25, i32 %26)
%28 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%29 = call i32 @perror(i8* %28)
store i32 -1, i32* %3
br label %61
30: ; preds = %2
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%32 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%33 = load i32, i32* @stdin
%34 = call i32 @fgets(i8* %32, i32 32, i32 %33)
%35 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%36 = call i32 (i8*, i8*, ...) @sscanf(i8* %35, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%38 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%39 = load i32, i32* @stdin
%40 = call i32 @fgets(i8* %38, i32 32, i32 %39)
%41 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%42 = call i32 (i8*, i8*, ...) @sscanf(i8* %41, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%43 = load i32, i32* %12
%44 = load i32, i32* %8
%45 = load i32, i32* %9
%46 = call i32 @remoteGCD(i32 %43, i32 %44, i32 %45, i32* %10)
%47 = load i32, i32* %8
%48 = load i32, i32* %9
%49 = load i32, i32* %10
%50 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %47, i32 %48, i32 %49)
%51 = load i32, i32* %12
%52 = load i32, i32* %8
%53 = load i32, i32* %9
%54 = call i32 @remoteLCM(i32 %51, i32 %52, i32 %53, i32* %11)
%55 = load i32, i32* %8
%56 = load i32, i32* %9
%57 = load i32, i32* %11
%58 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %55, i32 %56, i32 %57)
%59 = load i32, i32* %12
%60 = call i32 @close(i32 %59)
store i32 0, i32* %3
br label %61
61: ; preds = %30, %21
%62 = load i32, i32* %3
ret i32 %62
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [29 x i8] c"I couldn't connect to %s:%d\0A\00"
@.str.2 = [27 x i8] c"give me a natural number: \00"
@stdin = global i32 0
@.str.3 = [3 x i8] c"%u\00"
@.str.4 = [15 x i8] c"gcd(%u,%u)=%u\0A\00"
@.str.5 = [15 x i8] c"lcm(%u,%u)=%u\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [32 x i8]
%4 = alloca [32 x i8]
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = getelementptr inbounds [32 x i8], [32 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [32 x i8], [32 x i8]* %4, i64 0, i64 0
%13 = bitcast i32* %5 to i8*
%14 = bitcast i32* %6 to i8*
%15 = bitcast i32* %7 to i8*
%16 = bitcast i32* %8 to i8*
%17 = bitcast i32* %9 to i8*
%18 = bitcast i32* %10 to i8*
%19 = getelementptr inbounds i8*, i8** %1, i64 1
%20 = load i8*, i8** %19
%21 = call i32 (i8*, i8*, ...) @sscanf(i8* %20, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %10)
%22 = load i32, i32* %10
%23 = call i64 @connectToServer(i32* %9, i32 %22)
%24 = icmp eq i64 %23, 0
br i1 %24, label %30, label %25
25: ; preds = %2
%26 = load i8*, i8** %19
%27 = load i32, i32* %10
%28 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %26, i32 %27)
%29 = call i32 @perror(i8* %11)
br label %57
30: ; preds = %2
%31 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%32 = load i32, i32* @stdin
%33 = call i32 @fgets(i8* %11, i32 32, i32 %32)
%34 = call i32 (i8*, i8*, ...) @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%35 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%36 = load i32, i32* @stdin
%37 = call i32 @fgets(i8* %12, i32 32, i32 %36)
%38 = call i32 (i8*, i8*, ...) @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%39 = load i32, i32* %9
%40 = load i32, i32* %5
%41 = load i32, i32* %6
%42 = call i32 @remoteGCD(i32 %39, i32 %40, i32 %41, i32* %7)
%43 = load i32, i32* %5
%44 = load i32, i32* %6
%45 = load i32, i32* %7
%46 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %43, i32 %44, i32 %45)
%47 = load i32, i32* %9
%48 = load i32, i32* %5
%49 = load i32, i32* %6
%50 = call i32 @remoteLCM(i32 %47, i32 %48, i32 %49, i32* %8)
%51 = load i32, i32* %5
%52 = load i32, i32* %6
%53 = load i32, i32* %8
%54 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %51, i32 %52, i32 %53)
%55 = load i32, i32* %9
%56 = call i32 @close(i32 %55)
br label %57
57: ; preds = %30, %25
%58 = phi i32 [ -1, %25 ], [ 0, %30 ]
ret i32 %58
}