#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 u_int64_t;
typedef int u_int32_t;

/* Variables and functions */
int multi_thread_main(int, int, int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int main(int argc, char *argv[]) {
  bool error = false;
  if (argc != 4) {
    printf("Usage:\n");
    printf(" %s client_count loops msg_count\n", argv[0]);
    return 1;
  }
  u_int32_t client_count;
  sscanf(argv[1], "%u", &client_count);
  u_int64_t loops;
  sscanf(argv[2], "%lu", &loops);
  u_int32_t msg_count;
  sscanf(argv[3], "%i", &msg_count);
  printf("test client_count=%u loops=%lu msg_count=%u\n", client_count, loops,
         msg_count);
  error |= multi_thread_main(client_count, loops, msg_count);
  if (!error) {
    printf("Success\n");
  }
  return error ? 1 : 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)
movl   $0x0,-0x14(%rbp)
cmpl   $0x4,-0x8(%rbp)
je     1186 <main+0x56>
lea    0xea2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1224 <main+0xf4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe95(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe80(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe6c(%rip),%rsi
lea    -0x20(%rbp),%rdx
call   1040 <sscanf@plt>
mov    -0x18(%rbp),%esi
mov    -0x1c(%rbp),%edx
mov    -0x20(%rbp),%ecx
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%edi
mov    -0x1c(%rbp),%esi
mov    -0x20(%rbp),%edx
call   1050 <multi_thread_main@plt>
or     -0x14(%rbp),%eax
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    1211 <main+0xe1>
lea    0xe57(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%edx
xor    %eax,%eax
mov    $0x1,%ecx
cmp    $0x0,%edx
cmovne %ecx,%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    %rsi,%rbx
cmp    $0x4,%edi
jne    11d6 <main+0x96>
mov    0x8(%rbx),%rdi
lea    0xec6(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1050 <sscanf@plt>
mov    0x10(%rbx),%rdi
lea    0xeb4(%rip),%rsi
lea    0x8(%rsp),%rdx
call   1050 <sscanf@plt>
mov    0x18(%rbx),%rdi
lea    0xea3(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1050 <sscanf@plt>
mov    0xc(%rsp),%esi
mov    0x8(%rsp),%edx
mov    0x4(%rsp),%ecx
lea    0xe89(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
call   1060 <multi_thread_main@plt>
mov    %eax,%ebx
test   %eax,%eax
jne    11cd <main+0x8d>
lea    0xe91(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
test   %ebx,%ebx
setne  %al
jmp    11f8 <main+0xb8>
lea    0xe84(%rip),%rdi
call   1030 <puts@plt>
mov    (%rbx),%rsi
lea    0xe14(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    $0x1,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"Usage:\0A\00"
@.str.1 = [34 x i8] c" %s client_count loops msg_count\0A\00"
@.str.2 = [3 x i8] c"%u\00"
@.str.3 = [4 x i8] c"%lu\00"
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [45 x i8] c"test client_count=%u loops=%lu msg_count=%u\0A\00"
@.str.6 = [9 x i8] c"Success\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
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 0, i32* %6
%10 = load i32, i32* %4
%11 = icmp ne i32 %10, 4
br i1 %11, label %12, label %18
12: ; preds = %2
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%14 = load i8**, i8*** %5
%15 = getelementptr inbounds i8*, i8** %14, i64 0
%16 = load i8*, i8** %15
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %16)
store i32 1, i32* %3
br label %50
18: ; preds = %2
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 1
%21 = load i8*, i8** %20
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%23 = load i8**, i8*** %5
%24 = getelementptr inbounds i8*, i8** %23, i64 2
%25 = load i8*, i8** %24
%26 = call i32 @sscanf(i8* %25, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %8)
%27 = load i8**, i8*** %5
%28 = getelementptr inbounds i8*, i8** %27, i64 3
%29 = load i8*, i8** %28
%30 = call i32 @sscanf(i8* %29, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %9)
%31 = load i32, i32* %7
%32 = load i32, i32* %8
%33 = load i32, i32* %9
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %31, i32 %32, i32 %33)
%35 = load i32, i32* %7
%36 = load i32, i32* %8
%37 = load i32, i32* %9
%38 = call i32 @multi_thread_main(i32 %35, i32 %36, i32 %37)
%39 = load i32, i32* %6
%40 = or i32 %39, %38
store i32 %40, i32* %6
%41 = load i32, i32* %6
%42 = icmp ne i32 %41, 0
br i1 %42, label %45, label %43
43: ; preds = %18
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
br label %45
45: ; preds = %43, %18
%46 = load i32, i32* %6
%47 = icmp ne i32 %46, 0
%48 = zext i1 %47 to i64
%49 = select i1 %47, i32 1, i32 0
store i32 %49, i32* %3
br label %50
50: ; preds = %45, %12
%51 = load i32, i32* %3
ret i32 %51
}

LLVM IR (-O2):
@.str.1 = [34 x i8] c" %s client_count loops msg_count\0A\00"
@.str.2 = [3 x i8] c"%u\00"
@.str.3 = [4 x i8] c"%lu\00"
@.str.4 = [3 x i8] c"%i\00"
@.str.5 = [45 x i8] c"test client_count=%u loops=%lu msg_count=%u\0A\00"
@str = [8 x i8] c"Success\00"
@str.7 = [7 x i8] c"Usage:\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = icmp eq i32 %0, 4
br i1 %6, label %11, label %7
7: ; preds = %2
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([7 x i8], [7 x i8]* @str.7, i64 0, i64 0))
%9 = load i8*, i8** %1
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([34 x i8], [34 x i8]* @.str.1, i64 0, i64 0), i8* %9)
br label %38
11: ; preds = %2
%12 = bitcast i32* %3 to i8*
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %3)
%16 = bitcast i32* %4 to i8*
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = call i32 @sscanf(i8* %18, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0), i32* %4)
%20 = bitcast i32* %5 to i8*
%21 = getelementptr inbounds i8*, i8** %1, i64 3
%22 = load i8*, i8** %21
%23 = call i32 @sscanf(i8* %22, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %5)
%24 = load i32, i32* %3
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([45 x i8], [45 x i8]* @.str.5, i64 0, i64 0), i32 %24, i32 %25, i32 %26)
%28 = load i32, i32* %3
%29 = load i32, i32* %4
%30 = load i32, i32* %5
%31 = call i32 @multi_thread_main(i32 %28, i32 %29, i32 %30)
%32 = icmp eq i32 %31, 0
br i1 %32, label %33, label %35
33: ; preds = %11
%34 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @str, i64 0, i64 0))
br label %35
35: ; preds = %33, %11
%36 = xor i1 %32, true
%37 = zext i1 %36 to i32
br label %38
38: ; preds = %35, %7
%39 = phi i32 [ 1, %7 ], [ %37, %35 ]
ret i32 %39
}