#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*/ printf(char *);
scalar_t__ test1();
scalar_t__ test2();
scalar_t__ test3();
scalar_t__ test4();
int main() {
  int error = 0;
  error += test1();
  error += test2();
  error += test3();
  error += test4();
  if (!error)
    printf("native instructions test OK\n");
  else
    printf("native instructions test failed\n");
  return error;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
mov    $0x0,%al
call   1040 <test1@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1070 <test2@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1030 <test3@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
mov    $0x0,%al
call   1060 <test4@plt>
mov    %rax,%rcx
movslq -0x8(%rbp),%rax
add    %rcx,%rax
mov    %eax,-0x8(%rbp)
cmpl   $0x0,-0x8(%rbp)
jne    11d1 <main+0x81>
lea    0xe39(%rip),%rdi
call   1050 <printf@plt>
jmp    11dd <main+0x8d>
lea    0xe45(%rip),%rdi
call   1050 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
xor    %eax,%eax
call   1050 <test1@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1070 <test2@plt>
mov    %rax,%r15
add    %r14d,%r15d
xor    %eax,%eax
call   1040 <test3@plt>
mov    %rax,%rbx
add    %r15d,%ebx
xor    %eax,%eax
call   1060 <test4@plt>
mov    %rax,%r14
add    %ebx,%r14d
lea    0xe73(%rip),%rax
lea    0xe88(%rip),%rdi
cmove  %rax,%rdi
call   1030 <puts@plt>
mov    %r14d,%eax
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [29 x i8] c"native instructions test OK\0A\00"
@.str.1 = [33 x i8] c"native instructions test failed\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
%3 = call i64 (...) @test1()
%4 = load i32, i32* %2
%5 = sext i32 %4 to i64
%6 = add nsw i64 %5, %3
%7 = trunc i64 %6 to i32
store i32 %7, i32* %2
%8 = call i64 (...) @test2()
%9 = load i32, i32* %2
%10 = sext i32 %9 to i64
%11 = add nsw i64 %10, %8
%12 = trunc i64 %11 to i32
store i32 %12, i32* %2
%13 = call i64 (...) @test3()
%14 = load i32, i32* %2
%15 = sext i32 %14 to i64
%16 = add nsw i64 %15, %13
%17 = trunc i64 %16 to i32
store i32 %17, i32* %2
%18 = call i64 (...) @test4()
%19 = load i32, i32* %2
%20 = sext i32 %19 to i64
%21 = add nsw i64 %20, %18
%22 = trunc i64 %21 to i32
store i32 %22, i32* %2
%23 = load i32, i32* %2
%24 = icmp ne i32 %23, 0
br i1 %24, label %27, label %25
25: ; preds = %0
%26 = call i32 @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
br label %29
27: ; preds = %0
%28 = call i32 @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.1, i64 0, i64 0))
br label %29
29: ; preds = %27, %25
%30 = load i32, i32* %2
ret i32 %30
}

LLVM IR (-O2):
@str = [28 x i8] c"native instructions test OK\00"
@str.2 = [32 x i8] c"native instructions test failed\00"
define i32 @main() {
%1 = tail call i64 (...) @test1()
%2 = tail call i64 (...) @test2()
%3 = add i64 %2, %1
%4 = tail call i64 (...) @test3()
%5 = add i64 %3, %4
%6 = tail call i64 (...) @test4()
%7 = add i64 %5, %6
%8 = trunc i64 %7 to i32
%9 = icmp eq i32 %8, 0
%10 = select i1 %9, i8* getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0), i8* getelementptr inbounds ([32 x i8], [32 x i8]* @str.2, i64 0, i64 0)
%11 = tail call i32 @puts(i8* dereferenceable(1) %10)
ret i32 %8
}