#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 /*<<< orphan*/ SVCXPRT;

/* Variables and functions */
int /*<<< orphan*/ AF_UNIX;
int /*<<< orphan*/ IPPROTO_TCP;
int /*<<< orphan*/ SOCK_DGRAM;
int atoi(char *);
int /*<<< orphan*/ printf(char *, int);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ svc_destroy(int /*<<< orphan*/ *);
int /*<<< orphan*/ *svctcp_create(int, int /*<<< orphan*/, int /*<<< orphan*/);
int main(int argn, char *argc[]) {
  int run_mode = 0;
  int test_status = 1;
  int sock = 600;
  SVCXPRT *svcr = NULL;
  int nbCall = atoi(argc[3]);
  int nbOk = 0;
  int i;
  sock = socket(AF_UNIX, SOCK_DGRAM, IPPROTO_TCP);
  for (i = 0; i < nbCall; i++) {
    svcr = svctcp_create(sock, 0, 0);
    if (svcr != NULL)
      nbOk++;
  }
  if (run_mode == 1) {
    printf("Aimed : %d\n", nbCall);
    printf("Got : %d\n", nbOk);
  }
  test_status = (nbOk == nbCall) ? 0 : 1;
  svc_destroy(svcr);
  printf("%d\n", test_status);
  return test_status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
movl   $0x1,-0x18(%rbp)
movl   $0x258,-0x1c(%rbp)
movq   $0x0,-0x28(%rbp)
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
call   1060 <atoi@plt>
mov    %eax,-0x2c(%rbp)
movl   $0x0,-0x30(%rbp)
mov    0x2e47(%rip),%rax
mov    (%rax),%edi
mov    0x2e2e(%rip),%rax
mov    (%rax),%esi
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
call   1070 <socket@plt>
mov    %eax,-0x1c(%rbp)
movl   $0x0,-0x34(%rbp)
mov    -0x34(%rbp),%eax
cmp    -0x2c(%rbp),%eax
jge    1207 <main+0xb7>
mov    -0x1c(%rbp),%edi
xor    %edx,%edx
mov    %edx,%esi
call   1030 <svctcp_create@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
je     11f4 <main+0xa4>
mov    -0x30(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x30(%rbp)
jmp    11f9 <main+0xa9>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    11c4 <main+0x74>
cmpl   $0x1,-0x14(%rbp)
jne    122f <main+0xdf>
mov    -0x2c(%rbp),%esi
lea    0xde5(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%esi
lea    0xde2(%rip),%rdi
call   1040 <printf@plt>
mov    -0x30(%rbp),%edx
mov    -0x2c(%rbp),%esi
mov    $0x1,%eax
xor    %ecx,%ecx
cmp    %esi,%edx
cmove  %ecx,%eax
mov    %eax,-0x18(%rbp)
mov    -0x28(%rbp),%rdi
call   1050 <svc_destroy@plt>
mov    -0x18(%rbp),%esi
lea    0xdb1(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    0x18(%rsi),%rdi
call   1060 <atoi@plt>
mov    %eax,%r14d
mov    0x2e7e(%rip),%rax
mov    (%rax),%edi
mov    0x2e65(%rip),%rax
mov    (%rax),%esi
mov    0x2e64(%rip),%rax
mov    (%rax),%edx
call   1070 <socket@plt>
test   %r14d,%r14d
jle    11aa <main+0x5a>
mov    %eax,%r15d
xor    %ebx,%ebx
mov    %r14d,%ebp
mov    %r15d,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1030 <svctcp_create@plt>
cmp    $0x1,%rax
sbb    $0xffffffff,%ebx
add    $0xffffffff,%ebp
jne    1190 <main+0x40>
jmp    11ae <main+0x5e>
xor    %eax,%eax
xor    %ebx,%ebx
xor    %ebp,%ebp
cmp    %r14d,%ebx
setne  %bpl
mov    %rax,%rdi
call   1050 <svc_destroy@plt>
lea    0xe3a(%rip),%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@AF_UNIX = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str = [12 x i8] c"Aimed : %d\0A\00"
@.str.1 = [10 x i8] c"Got : %d\0A\00"
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32*
%10 = alloca i32
%11 = alloca i32
%12 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
store i32 1, i32* %7
store i32 600, i32* %8
store i32* null, i32** %9
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 3
%15 = load i8*, i8** %14
%16 = call i32 @atoi(i8* %15)
store i32 %16, i32* %10
store i32 0, i32* %11
%17 = load i32, i32* @AF_UNIX
%18 = load i32, i32* @SOCK_DGRAM
%19 = load i32, i32* @IPPROTO_TCP
%20 = call i32 @socket(i32 %17, i32 %18, i32 %19)
store i32 %20, i32* %8
store i32 0, i32* %12
br label %21
21: ; preds = %34, %2
%22 = load i32, i32* %12
%23 = load i32, i32* %10
%24 = icmp slt i32 %22, %23
br i1 %24, label %25, label %37
25: ; preds = %21
%26 = load i32, i32* %8
%27 = call i32* @svctcp_create(i32 %26, i32 0, i32 0)
store i32* %27, i32** %9
%28 = load i32*, i32** %9
%29 = icmp ne i32* %28, null
br i1 %29, label %30, label %33
30: ; preds = %25
%31 = load i32, i32* %11
%32 = add nsw i32 %31, 1
store i32 %32, i32* %11
br label %33
33: ; preds = %30, %25
br label %34
34: ; preds = %33
%35 = load i32, i32* %12
%36 = add nsw i32 %35, 1
store i32 %36, i32* %12
br label %21
37: ; preds = %21
%38 = load i32, i32* %6
%39 = icmp eq i32 %38, 1
br i1 %39, label %40, label %45
40: ; preds = %37
%41 = load i32, i32* %10
%42 = call i32 @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %41)
%43 = load i32, i32* %11
%44 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.1, i64 0, i64 0), i32 %43)
br label %45
45: ; preds = %40, %37
%46 = load i32, i32* %11
%47 = load i32, i32* %10
%48 = icmp eq i32 %46, %47
%49 = zext i1 %48 to i64
%50 = select i1 %48, i32 0, i32 1
store i32 %50, i32* %7
%51 = load i32*, i32** %9
%52 = call i32 @svc_destroy(i32* %51)
%53 = load i32, i32* %7
%54 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %53)
%55 = load i32, i32* %7
ret i32 %55
}

LLVM IR (-O2):
@AF_UNIX = global i32 0
@SOCK_DGRAM = global i32 0
@IPPROTO_TCP = global i32 0
@.str.2 = [4 x i8] c"%d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 3
%4 = load i8*, i8** %3
%5 = tail call i32 @atoi(i8* %4)
%6 = load i32, i32* @AF_UNIX
%7 = load i32, i32* @SOCK_DGRAM
%8 = load i32, i32* @IPPROTO_TCP
%9 = tail call i32 @socket(i32 %6, i32 %7, i32 %8)
%10 = icmp sgt i32 %5, 0
br i1 %10, label %11, label %20
11: ; preds = %2, %11
%12 = phi i32 [ %18, %11 ], [ 0, %2 ]
%13 = phi i32 [ %17, %11 ], [ 0, %2 ]
%14 = tail call i32* @svctcp_create(i32 %9, i32 0, i32 0)
%15 = icmp ne i32* %14, null
%16 = zext i1 %15 to i32
%17 = add nuw nsw i32 %13, %16
%18 = add nuw nsw i32 %12, 1
%19 = icmp eq i32 %18, %5
br i1 %19, label %20, label %11
20: ; preds = %11, %2
%21 = phi i32* [ null, %2 ], [ %14, %11 ]
%22 = phi i32 [ 0, %2 ], [ %17, %11 ]
%23 = icmp ne i32 %22, %5
%24 = zext i1 %23 to i32
%25 = tail call i32 @svc_destroy(i32* %21)
%26 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %24)
ret i32 %24
}