#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*/ fprintf(int /*<<< orphan*/, char *, int const, int,
                           int const);
int /*<<< orphan*/ printf(char *, int const, int const);
int /*<<< orphan*/ stderr;
int test(int const);
int main(void) {
  const int testval = -7;
  const int expected = 0;
  int ret = test(testval);
  if (ret != expected) {
    fprintf(stderr, "ERROR: test(%d) returned %d instead of %d\n", testval, ret,
            expected);
    return 1;
  }
  printf("OK: test(%d) returned %d\n", testval, expected);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0xfffffff9,-0x8(%rbp)
movl   $0x0,-0xc(%rbp)
mov    $0xfffffff9,%edi
call   1050 <test@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
je     1190 <main+0x60>
mov    0x2e75(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%ecx
lea    0xe89(%rip),%rsi
mov    $0xfffffff9,%edx
xor    %r8d,%r8d
call   1040 <fprintf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11aa <main+0x7a>
lea    0xe94(%rip),%rdi
mov    $0xfffffff9,%esi
xor    %edx,%edx
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
mov    $0xfffffff9,%edi
call   1050 <test@plt>
test   %eax,%eax
je     1165 <main+0x35>
mov    0x2e9a(%rip),%rcx
mov    (%rcx),%edi
lea    0xeb1(%rip),%rsi
mov    $0xfffffff9,%edx
mov    %eax,%ecx
xor    %r8d,%r8d
call   1040 <fprintf@plt>
mov    $0x1,%ebx
jmp    117a <main+0x4a>
lea    0xebf(%rip),%rdi
xor    %ebx,%ebx
mov    $0xfffffff9,%esi
xor    %edx,%edx
call   1030 <printf@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@stderr = global i32 0
@.str = [43 x i8] c"ERROR: test(%d) returned %d instead of %d\0A\00"
@.str.1 = [26 x i8] c"OK: test(%d) returned %d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
store i32 -7, i32* %2
store i32 0, i32* %3
%5 = call i32 @test(i32 -7)
store i32 %5, i32* %4
%6 = load i32, i32* %4
%7 = icmp ne i32 %6, 0
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = load i32, i32* @stderr
%10 = load i32, i32* %4
%11 = call i32 @fprintf(i32 %9, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 -7, i32 %10, i32 0)
store i32 1, i32* %1
br label %14
12: ; preds = %0
%13 = call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 -7, i32 0)
store i32 0, i32* %1
br label %14
14: ; preds = %12, %8
%15 = load i32, i32* %1
ret i32 %15
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [43 x i8] c"ERROR: test(%d) returned %d instead of %d\0A\00"
@.str.1 = [26 x i8] c"OK: test(%d) returned %d\0A\00"
define i32 @main() {
%1 = tail call i32 @test(i32 -7)
%2 = icmp eq i32 %1, 0
br i1 %2, label %6, label %3
3: ; preds = %0
%4 = load i32, i32* @stderr
%5 = tail call i32 @fprintf(i32 %4, i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str, i64 0, i64 0), i32 -7, i32 %1, i32 0)
br label %8
6: ; preds = %0
%7 = tail call i32 @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.1, i64 0, i64 0), i32 -7, i32 0)
br label %8
8: ; preds = %6, %3
%9 = phi i32 [ 1, %3 ], [ 0, %6 ]
ret i32 %9
}