#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 */
typedef int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ send(int, char *, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ sprintf(char *, char *, int, int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ waitFrame(int, char *, int);
int remoteGCD(int sock, uint32_t n, uint32_t m, uint32_t *pResult) {
  char str[32];
  sprintf(str, "gcd %u %u$", n, m);
  send(sock, str, strlen(str), 0);
  waitFrame(sock, str, 32);
  sscanf(str, "%d", pResult);
  return 0;
}


x86 assembly (clang, -O0):
<remoteGCD>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
mov    %edx,-0xc(%rbp)
mov    %rcx,-0x18(%rbp)
lea    -0x40(%rbp),%rdi
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe8a(%rip),%rsi
call   1070 <sprintf@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x4c(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x4c(%rbp),%edi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    -0x4(%rbp),%edi
lea    -0x40(%rbp),%rsi
mov    $0x20,%edx
call   1060 <waitFrame@plt>
lea    -0x40(%rbp),%rdi
mov    -0x18(%rbp),%rdx
lea    0xe49(%rip),%rsi
call   1050 <sscanf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<remoteGCD>:
push   %rbp
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    %rcx,%r14
mov    %edx,%ecx
mov    %esi,%edx
mov    %edi,%ebp
lea    0xe98(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1070 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
xor    %ecx,%ecx
call   1040 <send@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    $0x20,%edx
call   1060 <waitFrame@plt>
lea    0xe6c(%rip),%rsi
mov    %rbx,%rdi
mov    %r14,%rdx
call   1050 <sscanf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@.str = [11 x i8] c"gcd %u %u$\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @remoteGCD(i32 %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32*
%9 = alloca [32 x i8]
store i32 %0, i32* %5
store i32 %1, i32* %6
store i32 %2, i32* %7
store i32* %3, i32** %8
%10 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%11 = load i32, i32* %6
%12 = load i32, i32* %7
%13 = call i32 @sprintf(i8* %10, i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %11, i32 %12)
%14 = load i32, i32* %5
%15 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%16 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%17 = call i32 @strlen(i8* %16)
%18 = call i32 @send(i32 %14, i8* %15, i32 %17, i32 0)
%19 = load i32, i32* %5
%20 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%21 = call i32 @waitFrame(i32 %19, i8* %20, i32 32)
%22 = getelementptr inbounds [32 x i8], [32 x i8]* %9, i64 0, i64 0
%23 = load i32*, i32** %8
%24 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %23)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"gcd %u %u$\00"
@.str.1 = [3 x i8] c"%d\00"
define i32 @remoteGCD(i32 %0, i32 %1, i32 %2, i32* %3) {
%5 = alloca [32 x i8]
%6 = getelementptr inbounds [32 x i8], [32 x i8]* %5, i64 0, i64 0
%7 = call i32 @sprintf(i8* %6, i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i32 %1, i32 %2)
%8 = call i32 @strlen(i8* %6)
%9 = call i32 @send(i32 %0, i8* %6, i32 %8, i32 0)
%10 = call i32 @waitFrame(i32 %0, i8* %6, i32 32)
%11 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
ret i32 0
}