#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*/ int_to_string(int, char *);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ puts(char *);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
int string_length(char *);
int /*<<< orphan*/ string_rev(char *);
int string_to_int(char *);
int main(void) {
  bool correct = true;
  char s1[100] = "Hello, world!";
  char s2[100] = "!dlrow ,olleH";
  string_rev(s1);
  if (strcmp(s1, s2)) {
    correct = false;
    printf("string_rev() failed\n");
    printf("'%s', '%s'\n", s1, s2);
  }
  if (string_length(s1) != 13) {
    correct = false;
    printf("string_length() failed\n");
  }
  strcpy(s1, "314159");
  int n = string_to_int(s1);
  if (n != 314159) {
    correct = false;
    printf("string_to_int() failed\n");
    printf("%d\n", n);
  }
  int_to_string(918273, s1);
  if (strcmp(s1, "918273")) {
    correct = false;
    printf("int_to_string() failed\n");
  }
  if (correct) {
    puts("All tests passed.");
  } else {
    puts("Some tests FAILED.");
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0xf0,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x1,-0x8(%rbp)
lea    -0x70(%rbp),%rdi
lea    0xe4c(%rip),%rsi
mov    $0x64,%edx
call   1080 <memcpy@plt>
lea    -0xe0(%rbp),%rdi
lea    0xea4(%rip),%rsi
mov    $0x64,%edx
call   1080 <memcpy@plt>
lea    -0x70(%rbp),%rdi
call   1090 <string_rev@plt>
lea    -0x70(%rbp),%rdi
lea    -0xe0(%rbp),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     1227 <main+0x97>
movl   $0x0,-0x8(%rbp)
lea    0xecd(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rsi
lea    -0xe0(%rbp),%rdx
lea    0xec9(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
call   10a0 <string_length@plt>
cmp    $0xd,%eax
je     124e <main+0xbe>
movl   $0x0,-0x8(%rbp)
lea    0xeae(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rdi
lea    0xeb4(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x70(%rbp),%rdi
call   1070 <string_to_int@plt>
mov    %eax,-0xe4(%rbp)
cmpl   $0x4cb2f,-0xe4(%rbp)
je     12a6 <main+0x116>
movl   $0x0,-0x8(%rbp)
lea    0xe89(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0xe4(%rbp),%esi
lea    0xe8d(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x70(%rbp),%rsi
mov    $0xe0301,%edi
call   10b0 <int_to_string@plt>
lea    -0x70(%rbp),%rdi
lea    0xe71(%rip),%rsi
call   1060 <strcmp@plt>
cmp    $0x0,%rax
je     12e3 <main+0x153>
movl   $0x0,-0x8(%rbp)
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
cmpl   $0x0,-0x8(%rbp)
je     12fe <main+0x16e>
lea    0xe5b(%rip),%rdi
call   1040 <puts@plt>
jmp    130a <main+0x17a>
lea    0xe5c(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0xf0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
sub    $0xd8,%rsp
movaps 0xec0(%rip),%xmm0
movaps %xmm0,0x50(%rsp)
movaps 0xea4(%rip),%xmm0
movaps %xmm0,0x40(%rsp)
movaps 0xe88(%rip),%xmm0
movaps %xmm0,0x30(%rsp)
movaps 0xe6c(%rip),%xmm0
movaps %xmm0,0x20(%rsp)
movaps 0xe50(%rip),%xmm0
movaps %xmm0,0x10(%rsp)
movaps 0xe34(%rip),%xmm0
movaps %xmm0,(%rsp)
movl   $0x0,0x60(%rsp)
movaps 0xee1(%rip),%xmm0
movaps %xmm0,0xc0(%rsp)
movaps 0xec2(%rip),%xmm0
movaps %xmm0,0xb0(%rsp)
movaps 0xea3(%rip),%xmm0
movaps %xmm0,0xa0(%rsp)
movaps 0xe84(%rip),%xmm0
movaps %xmm0,0x90(%rsp)
movaps 0xe65(%rip),%xmm0
movaps %xmm0,0x80(%rsp)
movaps 0xe46(%rip),%xmm0
movaps %xmm0,0x70(%rsp)
movl   $0x0,0xd0(%rsp)
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1080 <string_rev@plt>
lea    0x70(%rsp),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     127d <main+0xfd>
lea    0xefe(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6a(%rip),%rdi
xor    %ebp,%ebp
mov    %rsp,%rsi
lea    0x70(%rsp),%rdx
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1282 <main+0x102>
mov    $0x1,%ebp
mov    %rsp,%rdi
call   1090 <string_length@plt>
cmp    $0xd,%eax
je     129d <main+0x11d>
lea    0xeaf(%rip),%rdi
call   1040 <puts@plt>
xor    %ebp,%ebp
lea    0xe3c(%rip),%rsi
mov    %rsp,%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
call   1070 <string_to_int@plt>
cmp    $0x4cb2f,%eax
je     12de <main+0x15e>
mov    %eax,%ebx
lea    0xe67(%rip),%rdi
call   1040 <puts@plt>
lea    0xe14(%rip),%rdi
xor    %ebp,%ebp
mov    %ebx,%esi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rsp,%rbx
mov    $0xe0301,%edi
mov    %rbx,%rsi
call   10a0 <int_to_string@plt>
lea    0xdf6(%rip),%rsi
mov    %rbx,%rdi
call   1060 <strcmp@plt>
test   %rax,%rax
je     1317 <main+0x197>
lea    0xe0e(%rip),%rdi
call   1040 <puts@plt>
lea    0xdef(%rip),%rdi
jmp    1322 <main+0x1a2>
test   %ebp,%ebp
je     130e <main+0x18e>
lea    0xdd0(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
add    $0xd8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@__const.main.s1 = [100 x i8] c"Hello, world!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.s2 = [100 x i8] c"!dlrow ,olleH\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str = [21 x i8] c"string_rev() failed\0A\00"
@.str.1 = [12 x i8] c"'%s', '%s'\0A\00"
@.str.2 = [24 x i8] c"string_length() failed\0A\00"
@.str.3 = [7 x i8] c"314159\00"
@.str.4 = [24 x i8] c"string_to_int() failed\0A\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [7 x i8] c"918273\00"
@.str.7 = [24 x i8] c"int_to_string() failed\0A\00"
@.str.8 = [18 x i8] c"All tests passed.\00"
@.str.9 = [19 x i8] c"Some tests FAILED.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i8]
%4 = alloca [100 x i8]
%5 = alloca i32
store i32 0, i32* %1
store i32 1, i32* %2
%6 = bitcast [100 x i8]* %3 to i8*
%7 = bitcast [100 x i8]* %4 to i8*
%8 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%9 = call i32 @string_rev(i8* %8)
%10 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%11 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%12 = call i64 @strcmp(i8* %10, i8* %11)
%13 = icmp ne i64 %12, 0
br i1 %13, label %14, label %19
14: ; preds = %0
store i32 0, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%16 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%17 = getelementptr inbounds [100 x i8], [100 x i8]* %4, i64 0, i64 0
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %16, i8* %17)
br label %19
19: ; preds = %14, %0
%20 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%21 = call i32 @string_length(i8* %20)
%22 = icmp ne i32 %21, 13
br i1 %22, label %23, label %25
23: ; preds = %19
store i32 0, i32* %2
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.2, i64 0, i64 0))
br label %25
25: ; preds = %23, %19
%26 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%27 = call i32 @strcpy(i8* %26, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%28 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%29 = call i32 @string_to_int(i8* %28)
store i32 %29, i32* %5
%30 = load i32, i32* %5
%31 = icmp ne i32 %30, 314159
br i1 %31, label %32, label %36
32: ; preds = %25
store i32 0, i32* %2
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.4, i64 0, i64 0))
%34 = load i32, i32* %5
%35 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %34)
br label %36
36: ; preds = %32, %25
%37 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%38 = call i32 @int_to_string(i32 918273, i8* %37)
%39 = getelementptr inbounds [100 x i8], [100 x i8]* %3, i64 0, i64 0
%40 = call i64 @strcmp(i8* %39, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%41 = icmp ne i64 %40, 0
br i1 %41, label %42, label %44
42: ; preds = %36
store i32 0, i32* %2
%43 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.7, i64 0, i64 0))
br label %44
44: ; preds = %42, %36
%45 = load i32, i32* %2
%46 = icmp ne i32 %45, 0
br i1 %46, label %47, label %49
47: ; preds = %44
%48 = call i32 @puts(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0))
br label %51
49: ; preds = %44
%50 = call i32 @puts(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0))
br label %51
51: ; preds = %49, %47
ret i32 0
}

LLVM IR (-O2):
@__const.main.s1 = [100 x i8] c"Hello, world!\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@__const.main.s2 = [100 x i8] c"!dlrow ,olleH\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00\00"
@.str.1 = [12 x i8] c"'%s', '%s'\0A\00"
@.str.3 = [7 x i8] c"314159\00"
@.str.5 = [4 x i8] c"%d\0A\00"
@.str.6 = [7 x i8] c"918273\00"
@.str.8 = [18 x i8] c"All tests passed.\00"
@.str.9 = [19 x i8] c"Some tests FAILED.\00"
@str = [23 x i8] c"int_to_string() failed\00"
@str.10 = [23 x i8] c"string_to_int() failed\00"
@str.11 = [23 x i8] c"string_length() failed\00"
@str.12 = [20 x i8] c"string_rev() failed\00"
define i32 @main() {
%1 = alloca [100 x i8]
%2 = alloca [100 x i8]
%3 = getelementptr inbounds [100 x i8], [100 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [100 x i8], [100 x i8]* %2, i64 0, i64 0
%5 = call i32 @string_rev(i8* %3)
%6 = call i64 @strcmp(i8* %3, i8* %4)
%7 = icmp eq i64 %6, 0
br i1 %7, label %11, label %8
8: ; preds = %0
%9 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @str.12, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %4)
br label %11
11: ; preds = %8, %0
%12 = phi i32 [ 0, %8 ], [ 1, %0 ]
%13 = call i32 @string_length(i8* %3)
%14 = icmp eq i32 %13, 13
br i1 %14, label %17, label %15
15: ; preds = %11
%16 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.11, i64 0, i64 0))
br label %17
17: ; preds = %15, %11
%18 = phi i32 [ 0, %15 ], [ %12, %11 ]
%19 = call i32 @strcpy(i8* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0))
%20 = call i32 @string_to_int(i8* %3)
%21 = icmp eq i32 %20, 314159
br i1 %21, label %25, label %22
22: ; preds = %17
%23 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str.10, i64 0, i64 0))
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i32 %20)
br label %25
25: ; preds = %22, %17
%26 = phi i32 [ 0, %22 ], [ %18, %17 ]
%27 = call i32 @int_to_string(i32 918273, i8* %3)
%28 = call i64 @strcmp(i8* %3, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.6, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %32, label %30
30: ; preds = %25
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %34
32: ; preds = %25
%33 = icmp eq i32 %26, 0
br i1 %33, label %34, label %35
34: ; preds = %30, %32
br label %35
35: ; preds = %32, %34
%36 = phi i8* [ getelementptr inbounds ([19 x i8], [19 x i8]* @.str.9, i64 0, i64 0), %34 ], [ getelementptr inbounds ([18 x i8], [18 x i8]* @.str.8, i64 0, i64 0), %32 ]
%37 = call i32 @puts(i8* dereferenceable(1) %36)
ret i32 0
}