#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*/ clacks_join_id(char *, char *);
int clacks_new_id(char *);
int /*<<< orphan*/ clacks_tag_id(char *, char *);
int /*<<< orphan*/ clacks_trace_string(char *, int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ stdout;
int main(int argc, char *argv[]) {
  char id[37];
  int ret;
  char j_id[37];
  ret = clacks_new_id(id);
  if (ret == -1) {
    fprintf(stdout, "Couldn't get a new ID\n");
    return -1;
  } else {
    fprintf(stdout, "ID: %s\n", id);
  }
  clacks_tag_id(id, "TEST");
  fprintf(stdout, "Testing tracing\n");
  clacks_trace_string("DIFFERENT STRING, %d", 100);
  fprintf(stdout, "Testing Joining\n");
  ret = clacks_new_id(j_id);
  if (ret == -1) {
    fprintf(stdout, "Error getting a new ID\n");
    return -1;
  } else {
    clacks_join_id(id, j_id);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
call   1060 <clacks_new_id@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
jne    119f <main+0x4f>
mov    0x2e5d(%rip),%rax
mov    (%rax),%edi
lea    0xe74(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1256 <main+0x106>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
lea    -0x40(%rbp),%rdx
lea    0xe64(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    -0x40(%rbp),%rdi
lea    0xe5a(%rip),%rsi
call   1040 <clacks_tag_id@plt>
mov    0x2e0f(%rip),%rax
mov    (%rax),%edi
lea    0xe4a(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    0xe4d(%rip),%rdi
mov    $0x64,%esi
call   1030 <clacks_trace_string@plt>
mov    0x2de7(%rip),%rax
mov    (%rax),%edi
lea    0xe48(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
lea    -0x70(%rbp),%rdi
call   1060 <clacks_new_id@plt>
mov    %eax,-0x44(%rbp)
cmpl   $0xffffffff,-0x44(%rbp)
jne    1242 <main+0xf2>
mov    0x2dba(%rip),%rax
mov    (%rax),%edi
lea    0xe2c(%rip),%rsi
mov    $0x0,%al
call   1050 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1256 <main+0x106>
lea    -0x40(%rbp),%rdi
lea    -0x70(%rbp),%rsi
call   1070 <clacks_join_id@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r14
push   %rbx
sub    $0x60,%rsp
mov    %rsp,%rdi
call   1060 <clacks_new_id@plt>
mov    0x2e79(%rip),%r14
mov    (%r14),%edi
cmp    $0xffffffff,%eax
je     11e5 <main+0x95>
lea    0xea1(%rip),%rsi
xor    %ebp,%ebp
mov    %rsp,%rbx
mov    %rbx,%rdx
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe93(%rip),%rsi
mov    %rbx,%rdi
call   1040 <clacks_tag_id@plt>
mov    (%r14),%edi
lea    0xe86(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0xe89(%rip),%rdi
mov    $0x64,%esi
call   1030 <clacks_trace_string@plt>
mov    (%r14),%edi
lea    0xe8a(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
lea    0x30(%rsp),%rdi
call   1060 <clacks_new_id@plt>
cmp    $0xffffffff,%eax
je     11ee <main+0x9e>
mov    %rsp,%rdi
lea    0x30(%rsp),%rsi
call   1070 <clacks_join_id@plt>
jmp    1204 <main+0xb4>
lea    0xe14(%rip),%rsi
jmp    11f8 <main+0xa8>
mov    (%r14),%edi
lea    0xe63(%rip),%rsi
xor    %eax,%eax
call   1050 <fprintf@plt>
mov    $0xffffffff,%ebp
mov    %ebp,%eax
add    $0x60,%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret

LLVM IR (-O0):
@stdout = global i32 0
@.str = [23 x i8] c"Couldn't get a new ID\0A\00"
@.str.1 = [8 x i8] c"ID: %s\0A\00"
@.str.2 = [5 x i8] c"TEST\00"
@.str.3 = [17 x i8] c"Testing tracing\0A\00"
@.str.4 = [21 x i8] c"DIFFERENT STRING, %d\00"
@.str.5 = [17 x i8] c"Testing Joining\0A\00"
@.str.6 = [24 x i8] c"Error getting a new ID\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [37 x i8]
%7 = alloca i32
%8 = alloca [37 x i8]
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = getelementptr inbounds [37 x i8], [37 x i8]* %6, i64 0, i64 0
%10 = call i32 @clacks_new_id(i8* %9)
store i32 %10, i32* %7
%11 = load i32, i32* %7
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %16
13: ; preds = %2
%14 = load i32, i32* @stdout
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
store i32 -1, i32* %3
br label %40
16: ; preds = %2
%17 = load i32, i32* @stdout
%18 = getelementptr inbounds [37 x i8], [37 x i8]* %6, i64 0, i64 0
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %17, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %18)
br label %20
20: ; preds = %16
%21 = getelementptr inbounds [37 x i8], [37 x i8]* %6, i64 0, i64 0
%22 = call i32 @clacks_tag_id(i8* %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%23 = load i32, i32* @stdout
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%25 = call i32 @clacks_trace_string(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 100)
%26 = load i32, i32* @stdout
%27 = call i32 (i32, i8*, ...) @fprintf(i32 %26, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%28 = getelementptr inbounds [37 x i8], [37 x i8]* %8, i64 0, i64 0
%29 = call i32 @clacks_new_id(i8* %28)
store i32 %29, i32* %7
%30 = load i32, i32* %7
%31 = icmp eq i32 %30, -1
br i1 %31, label %32, label %35
32: ; preds = %20
%33 = load i32, i32* @stdout
%34 = call i32 (i32, i8*, ...) @fprintf(i32 %33, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
store i32 -1, i32* %3
br label %40
35: ; preds = %20
%36 = getelementptr inbounds [37 x i8], [37 x i8]* %6, i64 0, i64 0
%37 = getelementptr inbounds [37 x i8], [37 x i8]* %8, i64 0, i64 0
%38 = call i32 @clacks_join_id(i8* %36, i8* %37)
br label %39
39: ; preds = %35
store i32 0, i32* %3
br label %40
40: ; preds = %39, %32, %13
%41 = load i32, i32* %3
ret i32 %41
}

LLVM IR (-O2):
@stdout = global i32 0
@.str = [23 x i8] c"Couldn't get a new ID\0A\00"
@.str.1 = [8 x i8] c"ID: %s\0A\00"
@.str.2 = [5 x i8] c"TEST\00"
@.str.3 = [17 x i8] c"Testing tracing\0A\00"
@.str.4 = [21 x i8] c"DIFFERENT STRING, %d\00"
@.str.5 = [17 x i8] c"Testing Joining\0A\00"
@.str.6 = [24 x i8] c"Error getting a new ID\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [37 x i8]
%4 = alloca [37 x i8]
%5 = getelementptr inbounds [37 x i8], [37 x i8]* %3, i64 0, i64 0
%6 = getelementptr inbounds [37 x i8], [37 x i8]* %4, i64 0, i64 0
%7 = call i32 @clacks_new_id(i8* %5)
%8 = icmp eq i32 %7, -1
%9 = load i32, i32* @stdout
br i1 %8, label %10, label %12
10: ; preds = %2
%11 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
br label %27
12: ; preds = %2
%13 = call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.1, i64 0, i64 0), i8* %5)
%14 = call i32 @clacks_tag_id(i8* %5, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%15 = load i32, i32* @stdout
%16 = call i32 (i32, i8*, ...) @fprintf(i32 %15, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @clacks_trace_string(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 100)
%18 = load i32, i32* @stdout
%19 = call i32 (i32, i8*, ...) @fprintf(i32 %18, i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.5, i64 0, i64 0))
%20 = call i32 @clacks_new_id(i8* %6)
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %25
22: ; preds = %12
%23 = load i32, i32* @stdout
%24 = call i32 (i32, i8*, ...) @fprintf(i32 %23, i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.6, i64 0, i64 0))
br label %27
25: ; preds = %12
%26 = call i32 @clacks_join_id(i8* %5, i8* %6)
br label %27
27: ; preds = %25, %22, %10
%28 = phi i32 [ -1, %10 ], [ -1, %22 ], [ 0, %25 ]
ret i32 %28
}