#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*/ printf(char *, ...);
int test_bad_connect(int);
int test_connect(int);
int test_socket();
int main(void) {
  if (1) {
    printf("test client Debug mode on\n");
  }
  int foo, bar, baz, qux;
  foo = test_socket();
  if (1) {
    printf("Return value of socket: %d\n", foo);
  }
  bar = test_connect(foo);
  if (1) {
    printf("Return value of connect: %d\n", bar);
  }
  baz = test_socket();
  qux = test_bad_connect(baz);
  if (1) {
    printf("Return value of connect: %d\n", bar);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <test_socket@plt>
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x4(%rbp),%edi
call   1040 <test_connect@plt>
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xeb1(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    $0x0,%al
call   1060 <test_socket@plt>
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%edi
call   1030 <test_bad_connect@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe8b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
lea    0xede(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
call   1070 <test_socket@plt>
mov    %eax,%ebx
lea    0xe90(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    %ebx,%edi
call   1050 <test_connect@plt>
mov    %eax,%ebx
lea    0xe93(%rip),%r14
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
call   1070 <test_socket@plt>
mov    %eax,%edi
call   1040 <test_bad_connect@plt>
mov    %r14,%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [27 x i8] c"test client Debug mode on\0A\00"
@.str.1 = [28 x i8] c"Return value of socket: %d\0A\00"
@.str.2 = [29 x i8] c"Return value of connect: %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str, i64 0, i64 0))
%6 = call i32 (...) @test_socket()
store i32 %6, i32* %1
%7 = load i32, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = load i32, i32* %1
%10 = call i32 @test_connect(i32 %9)
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %11)
%13 = call i32 (...) @test_socket()
store i32 %13, i32* %3
%14 = load i32, i32* %3
%15 = call i32 @test_bad_connect(i32 %14)
store i32 %15, i32* %4
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %16)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [28 x i8] c"Return value of socket: %d\0A\00"
@.str.2 = [29 x i8] c"Return value of connect: %d\0A\00"
@str = [26 x i8] c"test client Debug mode on\00"
define i32 @main() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (...) @test_socket()
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i32 %2)
%4 = tail call i32 @test_connect(i32 %2)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %4)
%6 = tail call i32 (...) @test_socket()
%7 = tail call i32 @test_bad_connect(i32 %6)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i32 %4)
ret i32 0
}