#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*/ checkArgs(int, char **);
int /*<<< orphan*/ close(int);
scalar_t__ connectToServer(int *, char *, 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;
  checkArgs(argc, argv);
  sscanf(argv[2], "%d", &port);
  if (connectToServer(&sock, argv[1], 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    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1040 <checkArgs@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe2f(%rip),%rsi
lea    -0x68(%rbp),%rdx
mov    $0x0,%al
call   10a0 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
mov    -0x68(%rbp),%edx
lea    -0x64(%rbp),%rdi
call   1070 <connectToServer@plt>
cmp    $0x0,%rax
je     122a <main+0x8a>
lea    -0x30(%rbp),%rdi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
mov    -0x68(%rbp),%ecx
lea    0xdf3(%rip),%rsi
call   10c0 <sprintf@plt>
lea    -0x30(%rbp),%rdi
call   10b0 <perror@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1301 <main+0x161>
lea    0xdef(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x30(%rbp),%rdi
mov    0x2da5(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1080 <fgets@plt>
lea    -0x30(%rbp),%rdi
lea    0xde1(%rip),%rsi
lea    -0x54(%rbp),%rdx
mov    $0x0,%al
call   10a0 <sscanf@plt>
lea    0xdb4(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x50(%rbp),%rdi
mov    0x2d6a(%rip),%rax
mov    (%rax),%edx
mov    $0x20,%esi
call   1080 <fgets@plt>
lea    -0x50(%rbp),%rdi
lea    0xda6(%rip),%rsi
lea    -0x58(%rbp),%rdx
mov    $0x0,%al
call   10a0 <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    0xd7c(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x64(%rbp),%edi
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
lea    -0x60(%rbp),%rcx
call   1090 <remoteLCM@plt>
mov    -0x54(%rbp),%esi
mov    -0x58(%rbp),%edx
mov    -0x60(%rbp),%ecx
lea    0xd62(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x64(%rbp),%edi
call   1060 <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
call   1040 <checkArgs@plt>
mov    0x10(%rbx),%rdi
lea    0xe41(%rip),%rsi
xor    %r14d,%r14d
lea    0x14(%rsp),%rdx
xor    %eax,%eax
call   10a0 <sscanf@plt>
mov    0x8(%rbx),%rsi
mov    0x14(%rsp),%edx
lea    0x10(%rsp),%rdi
call   1070 <connectToServer@plt>
test   %rax,%rax
jne    12db <main+0x13b>
lea    0xe30(%rip),%r15
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2de7(%rip),%r12
mov    (%r12),%edx
lea    0x20(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   1080 <fgets@plt>
lea    0xe1d(%rip),%rbx
lea    0xc(%rsp),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <sscanf@plt>
mov    %r15,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    (%r12),%edx
lea    0x40(%rsp),%rbp
mov    %rbp,%rdi
mov    $0x20,%esi
call   1080 <fgets@plt>
lea    0x8(%rsp),%rdx
mov    %rbp,%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   10a0 <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    0xdb3(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%edi
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
lea    0x18(%rsp),%rcx
call   1090 <remoteLCM@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0x18(%rsp),%ecx
lea    0xd92(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x10(%rsp),%edi
call   1060 <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    0xd19(%rip),%rsi
lea    0x20(%rsp),%rbx
mov    %rbx,%rdi
call   10c0 <sprintf@plt>
mov    %rbx,%rdi
call   10b0 <perror@plt>
mov    $0xffffffff,%r14d
jmp    12cb <main+0x12b>

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 i32, i32* %4
%15 = load i8**, i8*** %5
%16 = call i32 @checkArgs(i32 %14, i8** %15)
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = call i32 (i8*, i8*, ...) @sscanf(i8* %19, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %13)
%21 = load i8**, i8*** %5
%22 = getelementptr inbounds i8*, i8** %21, i64 1
%23 = load i8*, i8** %22
%24 = load i32, i32* %13
%25 = call i64 @connectToServer(i32* %12, i8* %23, i32 %24)
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %36
27: ; preds = %2
%28 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%29 = load i8**, i8*** %5
%30 = getelementptr inbounds i8*, i8** %29, i64 1
%31 = load i8*, i8** %30
%32 = load i32, i32* %13
%33 = call i32 @sprintf(i8* %28, i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %31, i32 %32)
%34 = getelementptr inbounds [32 x i8], [32 x i8]* %6, i64 0, i64 0
%35 = call i32 @perror(i8* %34)
store i32 -1, i32* %3
br label %67
36: ; preds = %2
%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]* %6, 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]* %6, 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* %8)
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%44 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%45 = load i32, i32* @stdin
%46 = call i32 @fgets(i8* %44, i32 32, i32 %45)
%47 = getelementptr inbounds [32 x i8], [32 x i8]* %7, i64 0, i64 0
%48 = call i32 (i8*, i8*, ...) @sscanf(i8* %47, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %9)
%49 = load i32, i32* %12
%50 = load i32, i32* %8
%51 = load i32, i32* %9
%52 = call i32 @remoteGCD(i32 %49, i32 %50, i32 %51, i32* %10)
%53 = load i32, i32* %8
%54 = load i32, i32* %9
%55 = load i32, i32* %10
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %53, i32 %54, i32 %55)
%57 = load i32, i32* %12
%58 = load i32, i32* %8
%59 = load i32, i32* %9
%60 = call i32 @remoteLCM(i32 %57, i32 %58, i32 %59, i32* %11)
%61 = load i32, i32* %8
%62 = load i32, i32* %9
%63 = load i32, i32* %11
%64 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %61, i32 %62, i32 %63)
%65 = load i32, i32* %12
%66 = call i32 @close(i32 %65)
store i32 0, i32* %3
br label %67
67: ; preds = %36, %27
%68 = load i32, i32* %3
ret i32 %68
}

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** %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 = tail call i32 @checkArgs(i32 %0, i8** %1)
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = call i32 (i8*, i8*, ...) @sscanf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %10)
%23 = getelementptr inbounds i8*, i8** %1, i64 1
%24 = load i8*, i8** %23
%25 = load i32, i32* %10
%26 = call i64 @connectToServer(i32* %9, i8* %24, i32 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %33, label %28
28: ; preds = %2
%29 = load i8*, i8** %23
%30 = load i32, i32* %10
%31 = call i32 @sprintf(i8* %11, i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i8* %29, i32 %30)
%32 = call i32 @perror(i8* %11)
br label %60
33: ; preds = %2
%34 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%35 = load i32, i32* @stdin
%36 = call i32 @fgets(i8* %11, i32 32, i32 %35)
%37 = call i32 (i8*, i8*, ...) @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %5)
%38 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%39 = load i32, i32* @stdin
%40 = call i32 @fgets(i8* %12, i32 32, i32 %39)
%41 = call i32 (i8*, i8*, ...) @sscanf(i8* %12, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.3, i64 0, i64 0), i32* %6)
%42 = load i32, i32* %9
%43 = load i32, i32* %5
%44 = load i32, i32* %6
%45 = call i32 @remoteGCD(i32 %42, i32 %43, i32 %44, i32* %7)
%46 = load i32, i32* %5
%47 = load i32, i32* %6
%48 = load i32, i32* %7
%49 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.4, i64 0, i64 0), i32 %46, i32 %47, i32 %48)
%50 = load i32, i32* %9
%51 = load i32, i32* %5
%52 = load i32, i32* %6
%53 = call i32 @remoteLCM(i32 %50, i32 %51, i32 %52, i32* %8)
%54 = load i32, i32* %5
%55 = load i32, i32* %6
%56 = load i32, i32* %8
%57 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.5, i64 0, i64 0), i32 %54, i32 %55, i32 %56)
%58 = load i32, i32* %9
%59 = call i32 @close(i32 %58)
br label %60
60: ; preds = %33, %28
%61 = phi i32 [ -1, %28 ], [ 0, %33 ]
ret i32 %61
}