#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*/ cnfInitRTL(int, char **);
int /*<<< orphan*/ cnfLock();
int /*<<< orphan*/ cnfUnlock();
int /*<<< orphan*/ ftestarg_(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strlen(char *);
int main() {
  int status;
  int iargc = 2;
  char *argv[2] = {"command", "hello"};
  char retval[] = "     ";
  cnfInitRTL(iargc, argv);
  cnfLock();
  ftestarg_(retval, strlen(retval));
  cnfUnlock();
  if (strcmp(retval, argv[1]) == 0) {
    printf("Correctly got '%s' and '%s'\n", argv[1], retval);
    status = EXIT_SUCCESS;
  } else {
    printf("Went horribly wrong. Got '%s' instead of '%s'\n", retval, argv[1]);
    status = EXIT_FAILURE;
  }
  return status;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x2,-0xc(%rbp)
mov    0x2c73(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0x2c70(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe6c(%rip),%eax
mov    %eax,-0x26(%rbp)
mov    0xe66(%rip),%ax
mov    %ax,-0x22(%rbp)
mov    -0xc(%rbp),%edi
lea    -0x20(%rbp),%rsi
call   1090 <cnfInitRTL@plt>
mov    $0x0,%al
call   1040 <cnfLock@plt>
lea    -0x26(%rbp),%rax
mov    %rax,-0x30(%rbp)
lea    -0x26(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x30(%rbp),%rdi
mov    %eax,%esi
call   1070 <ftestarg_@plt>
mov    $0x0,%al
call   1080 <cnfUnlock@plt>
lea    -0x26(%rbp),%rdi
mov    -0x18(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
jne    1222 <main+0xb2>
mov    -0x18(%rbp),%rsi
lea    -0x26(%rbp),%rdx
lea    0xe08(%rip),%rdi
call   1050 <printf@plt>
mov    0x2dc0(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
jmp    1242 <main+0xd2>
lea    -0x26(%rbp),%rsi
mov    -0x18(%rbp),%rdx
lea    0xe00(%rip),%rdi
call   1050 <printf@plt>
mov    0x2da3(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
movaps 0x2c84(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movw   $0x20,0xc(%rsp)
movl   $0x20202020,0x8(%rsp)
20
lea    0x10(%rsp),%rsi
mov    $0x2,%edi
call   1090 <cnfInitRTL@plt>
xor    %eax,%eax
call   1040 <cnfLock@plt>
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1070 <ftestarg_@plt>
xor    %eax,%eax
call   1080 <cnfUnlock@plt>
mov    0x18(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
mov    0x18(%rsp),%rdx
test   %rax,%rax
je     11f5 <main+0x85>
lea    0xe4f(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1050 <printf@plt>
mov    0x2ded(%rip),%rax
jmp    1213 <main+0xa3>
lea    0xe18(%rip),%rdi
lea    0x8(%rsp),%rax
mov    %rdx,%rsi
mov    %rax,%rdx
call   1050 <printf@plt>
mov    0x2dc5(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [8 x i8] c"command\00"
@.str.1 = [6 x i8] c"hello\00"
@__const.main.argv = [2 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0)]
@__const.main.retval = [6 x i8] c" \00"
@.str.2 = [29 x i8] c"Correctly got '%s' and '%s'\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.3 = [47 x i8] c"Went horribly wrong. Got '%s' instead of '%s'\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [2 x i8*]
%5 = alloca [6 x i8]
store i32 0, i32* %1
store i32 2, i32* %3
%6 = bitcast [2 x i8*]* %4 to i8*
%7 = bitcast [6 x i8]* %5 to i8*
%8 = load i32, i32* %3
%9 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 0
%10 = call i32 @cnfInitRTL(i32 %8, i8** %9)
%11 = call i32 (...) @cnfLock()
%12 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%13 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%14 = call i32 @strlen(i8* %13)
%15 = call i32 @ftestarg_(i8* %12, i32 %14)
%16 = call i32 (...) @cnfUnlock()
%17 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%18 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %17, i8* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %28
22: ; preds = %0
%23 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 1
%24 = load i8*, i8** %23
%25 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%26 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %24, i8* %25)
%27 = load i32, i32* @EXIT_SUCCESS
store i32 %27, i32* %2
br label %34
28: ; preds = %0
%29 = getelementptr inbounds [6 x i8], [6 x i8]* %5, i64 0, i64 0
%30 = getelementptr inbounds [2 x i8*], [2 x i8*]* %4, i64 0, i64 1
%31 = load i8*, i8** %30
%32 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %29, i8* %31)
%33 = load i32, i32* @EXIT_FAILURE
store i32 %33, i32* %2
br label %34
34: ; preds = %28, %22
%35 = load i32, i32* %2
ret i32 %35
}

LLVM IR (-O2):
@.str = [8 x i8] c"command\00"
@.str.1 = [6 x i8] c"hello\00"
@__const.main.argv = [2 x i8*] [i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i32 0, i32 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i32 0, i32 0)]
@__const.main.retval = [6 x i8] c" \00"
@.str.2 = [29 x i8] c"Correctly got '%s' and '%s'\0A\00"
@EXIT_SUCCESS = global i32 0
@.str.3 = [47 x i8] c"Went horribly wrong. Got '%s' instead of '%s'\0A\00"
@EXIT_FAILURE = global i32 0
define i32 @main() {
%1 = alloca [2 x i8*]
%2 = alloca [6 x i8]
%3 = bitcast [2 x i8*]* %1 to i8*
%4 = getelementptr inbounds [6 x i8], [6 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 0
%6 = call i32 @cnfInitRTL(i32 2, i8** %5)
%7 = call i32 (...) @cnfLock()
%8 = call i32 @strlen(i8* %4)
%9 = call i32 @ftestarg_(i8* %4, i32 %8)
%10 = call i32 (...) @cnfUnlock()
%11 = getelementptr inbounds [2 x i8*], [2 x i8*]* %1, i64 0, i64 1
%12 = load i8*, i8** %11
%13 = call i64 @strcmp(i8* %4, i8* %12)
%14 = icmp eq i64 %13, 0
%15 = load i8*, i8** %11
br i1 %14, label %16, label %18
16: ; preds = %0
%17 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.2, i64 0, i64 0), i8* %15, i8* %4)
br label %20
18: ; preds = %0
%19 = call i32 @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.3, i64 0, i64 0), i8* %4, i8* %15)
br label %20
20: ; preds = %18, %16
%21 = phi i32* [ @EXIT_SUCCESS, %16 ], [ @EXIT_FAILURE, %18 ]
%22 = load i32, i32* %21
ret i32 %22
}