#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 EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
int /*<<< orphan*/ parse_argv(int, char **);
int /*<<< orphan*/ printf(char *);
int run_paxos(int);
int /*<<< orphan*/ srandom(int /*<<< orphan*/);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int /*<<< orphan*/ worker_init();
int main(int argc, char **argv) {
  int ret;
  parse_argv(argc, argv);
  srandom(time(NULL));
  worker_init();
  printf("testing single-proposer case...\n");
  ret = run_paxos(0);
  if (ret) {
    fprintf(stderr, "run_paxos(0) failed with error code %d\n", ret);
    return EXIT_FAILURE;
  }
  printf("testing multi-proposer case...\n");
  ret = run_paxos(1);
  if (ret) {
    fprintf(stderr, "run_paxos(1) failed with error code %d\n", ret);
    return EXIT_FAILURE;
  }
  return EXIT_SUCCESS;
}


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    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
call   1080 <parse_argv@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
mov    $0x0,%al
call   1090 <worker_init@plt>
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
xor    %edi,%edi
call   1050 <run_paxos@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     11f2 <main+0x82>
mov    0x2e10(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe45(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2df0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    124a <main+0xda>
lea    0xe50(%rip),%rdi
call   1040 <printf@plt>
mov    $0x1,%edi
call   1050 <run_paxos@plt>
mov    %eax,-0x14(%rbp)
cmpl   $0x0,-0x14(%rbp)
je     123e <main+0xce>
mov    0x2dc4(%rip),%rax
mov    (%rax),%edi
mov    -0x14(%rbp),%edx
lea    0xe41(%rip),%rsi
call   1060 <fprintf@plt>
mov    0x2da4(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
jmp    124a <main+0xda>
mov    0x2d8b(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
call   1080 <parse_argv@plt>
xor    %edi,%edi
call   1070 <time@plt>
mov    %eax,%edi
call   1030 <srandom@plt>
xor    %eax,%eax
call   1090 <worker_init@plt>
lea    0xebe(%rip),%rdi
call   1040 <puts@plt>
xor    %edi,%edi
call   1050 <run_paxos@plt>
test   %eax,%eax
je     11b4 <main+0x44>
mov    0x2e37(%rip),%rcx
mov    (%rcx),%edi
lea    0xe4e(%rip),%rsi
jmp    11de <main+0x6e>
lea    0xeb5(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%edi
call   1050 <run_paxos@plt>
test   %eax,%eax
je     11f0 <main+0x80>
mov    0x2e0b(%rip),%rcx
mov    (%rcx),%edi
lea    0xe4a(%rip),%rsi
mov    %eax,%edx
call   1060 <fprintf@plt>
mov    0x2dec(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret
mov    0x2dd9(%rip),%rax
jmp    11ec <main+0x7c>

LLVM IR (-O0):
@.str = [33 x i8] c"testing single-proposer case...\0A\00"
@stderr = global i32 0
@.str.1 = [40 x i8] c"run_paxos(0) failed with error code %d\0A\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [32 x i8] c"testing multi-proposer case...\0A\00"
@.str.3 = [40 x i8] c"run_paxos(1) failed with error code %d\0A\00"
@EXIT_SUCCESS = global i32 0
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 = load i32, i32* %4
%8 = load i8**, i8*** %5
%9 = call i32 @parse_argv(i32 %7, i8** %8)
%10 = call i32 @time(i32* null)
%11 = call i32 @srandom(i32 %10)
%12 = call i32 (...) @worker_init()
%13 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
%14 = call i32 @run_paxos(i32 0)
store i32 %14, i32* %6
%15 = load i32, i32* %6
%16 = icmp ne i32 %15, 0
br i1 %16, label %17, label %22
17: ; preds = %2
%18 = load i32, i32* @stderr
%19 = load i32, i32* %6
%20 = call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %19)
%21 = load i32, i32* @EXIT_FAILURE
store i32 %21, i32* %3
br label %34
22: ; preds = %2
%23 = call i32 @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 @run_paxos(i32 1)
store i32 %24, i32* %6
%25 = load i32, i32* %6
%26 = icmp ne i32 %25, 0
br i1 %26, label %27, label %32
27: ; preds = %22
%28 = load i32, i32* @stderr
%29 = load i32, i32* %6
%30 = call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @EXIT_FAILURE
store i32 %31, i32* %3
br label %34
32: ; preds = %22
%33 = load i32, i32* @EXIT_SUCCESS
store i32 %33, i32* %3
br label %34
34: ; preds = %32, %27, %17
%35 = load i32, i32* %3
ret i32 %35
}

LLVM IR (-O2):
@stderr = global i32 0
@.str.1 = [40 x i8] c"run_paxos(0) failed with error code %d\0A\00"
@EXIT_FAILURE = global i32 0
@.str.3 = [40 x i8] c"run_paxos(1) failed with error code %d\0A\00"
@EXIT_SUCCESS = global i32 0
@str = [32 x i8] c"testing single-proposer case...\00"
@str.4 = [31 x i8] c"testing multi-proposer case...\00"
define i32 @main(i32 %0, i8** %1) {
%3 = tail call i32 @parse_argv(i32 %0, i8** %1)
%4 = tail call i32 @time(i32* null)
%5 = tail call i32 @srandom(i32 %4)
%6 = tail call i32 (...) @worker_init()
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%8 = tail call i32 @run_paxos(i32 0)
%9 = icmp eq i32 %8, 0
br i1 %9, label %13, label %10
10: ; preds = %2
%11 = load i32, i32* @stderr
%12 = tail call i32 @fprintf(i32 %11, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.1, i64 0, i64 0), i32 %8)
br label %20
13: ; preds = %2
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.4, i64 0, i64 0))
%15 = tail call i32 @run_paxos(i32 1)
%16 = icmp eq i32 %15, 0
br i1 %16, label %20, label %17
17: ; preds = %13
%18 = load i32, i32* @stderr
%19 = tail call i32 @fprintf(i32 %18, i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %15)
br label %20
20: ; preds = %13, %17, %10
%21 = phi i32* [ @EXIT_FAILURE, %10 ], [ @EXIT_FAILURE, %17 ], [ @EXIT_SUCCESS, %13 ]
%22 = load i32, i32* %21
ret i32 %22
}