#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 */
scalar_t__ isfin(int);
int /*<<< orphan*/ myclose(int);
int mylisten(int);
int /*<<< orphan*/ myreceive(int);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *);
int main(int argc, char *argv[]) {
  int fd;
  fd = mylisten(10220);
  if (fd < 0)
    perror("mylisten");
  myclose(fd);
  myreceive(fd);
  if (isfin(fd))
    printf("Complete the four way handshake\n");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x27ec,%edi
call   1060 <mylisten@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jge    1199 <main+0x39>
lea    0xe6c(%rip),%rdi
call   1080 <perror@plt>
mov    -0x14(%rbp),%edi
call   1030 <myclose@plt>
mov    -0x14(%rbp),%edi
call   1050 <myreceive@plt>
mov    -0x14(%rbp),%edi
call   1070 <isfin@plt>
cmp    $0x0,%rax
je     11c7 <main+0x67>
lea    0xe47(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0x27ec,%edi
call   1060 <mylisten@plt>
mov    %eax,%ebx
test   %eax,%eax
js     119b <main+0x3b>
mov    %ebx,%edi
call   1040 <myclose@plt>
mov    %ebx,%edi
call   1050 <myreceive@plt>
mov    %ebx,%edi
call   1070 <isfin@plt>
test   %rax,%rax
je     1197 <main+0x37>
lea    0xe77(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret
lea    0xe5e(%rip),%rdi
call   1080 <perror@plt>
jmp    1171 <main+0x11>

LLVM IR (-O0):
@.str = [9 x i8] c"mylisten\00"
@.str.1 = [33 x i8] c"Complete the four way handshake\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = call i32 @mylisten(i32 10220)
store i32 %7, i32* %6
%8 = load i32, i32* %6
%9 = icmp slt i32 %8, 0
br i1 %9, label %10, label %12
10: ; preds = %2
%11 = call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %12
12: ; preds = %10, %2
%13 = load i32, i32* %6
%14 = call i32 @myclose(i32 %13)
%15 = load i32, i32* %6
%16 = call i32 @myreceive(i32 %15)
%17 = load i32, i32* %6
%18 = call i64 @isfin(i32 %17)
%19 = icmp ne i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %12
%21 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %22
22: ; preds = %20, %12
ret i32 0
}

LLVM IR (-O2):
@.str = [9 x i8] c"mylisten\00"
@str = [32 x i8] c"Complete the four way handshake\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call i32 @mylisten(i32 10220)
%4 = icmp slt i32 %3, 0
br i1 %4, label %5, label %7
5: ; preds = %2
%6 = tail call i32 @perror(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0))
br label %7
7: ; preds = %5, %2
%8 = tail call i32 @myclose(i32 %3)
%9 = tail call i32 @myreceive(i32 %3)
%10 = tail call i64 @isfin(i32 %3)
%11 = icmp eq i64 %10, 0
br i1 %11, label %14, label %12
12: ; preds = %7
%13 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
br label %14
14: ; preds = %12, %7
ret i32 0
}