#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 S_IFBLK;
int S_IFCHR;
int S_IFDIR;
int S_IFIFO;
int S_IFLNK;
int S_IFMT;
int S_IFREG;
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ test_syscall(int);
int main(void) {
  test_syscall(0);
  test_syscall(0xffff);
  test_syscall(06);
  test_syscall(060);
  test_syscall(0600);
  test_syscall(024);
  test_syscall(S_IFREG);
  test_syscall(S_IFDIR | 06);
  test_syscall(S_IFLNK | 060);
  test_syscall(S_IFIFO | 0600);
  test_syscall(S_IFCHR | 024);
  test_syscall((0xffff & ~S_IFMT) | S_IFBLK);
  puts("+++ exited with 0 +++");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
xor    %edi,%edi
call   1040 <test_syscall@plt>
mov    $0xffff,%edi
call   1040 <test_syscall@plt>
mov    $0x6,%edi
call   1040 <test_syscall@plt>
mov    $0x30,%edi
call   1040 <test_syscall@plt>
mov    $0x180,%edi
call   1040 <test_syscall@plt>
mov    $0x14,%edi
call   1040 <test_syscall@plt>
mov    0x2e79(%rip),%rax
mov    (%rax),%edi
call   1040 <test_syscall@plt>
mov    0x2e2b(%rip),%rax
mov    (%rax),%edi
or     $0x6,%edi
call   1040 <test_syscall@plt>
mov    0x2e52(%rip),%rax
mov    (%rax),%edi
or     $0x30,%edi
call   1040 <test_syscall@plt>
mov    0x2e19(%rip),%rax
mov    (%rax),%edi
or     $0x180,%edi
call   1040 <test_syscall@plt>
mov    0x2e0d(%rip),%rax
mov    (%rax),%edi
or     $0x14,%edi
call   1040 <test_syscall@plt>
mov    0x2e0c(%rip),%rax
mov    (%rax),%edi
xor    $0xffffffff,%edi
and    $0xffff,%edi
mov    0x2df2(%rip),%rax
or     (%rax),%edi
call   1040 <test_syscall@plt>
lea    0xe1c(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
xor    %edi,%edi
call   1040 <test_syscall@plt>
mov    $0xffff,%edi
call   1040 <test_syscall@plt>
mov    $0x6,%edi
call   1040 <test_syscall@plt>
mov    $0x30,%edi
call   1040 <test_syscall@plt>
mov    $0x180,%ebx
mov    $0x180,%edi
call   1040 <test_syscall@plt>
mov    $0x14,%edi
call   1040 <test_syscall@plt>
mov    0x2e82(%rip),%rax
mov    (%rax),%edi
call   1040 <test_syscall@plt>
mov    0x2e34(%rip),%rax
mov    (%rax),%edi
or     $0x6,%edi
call   1040 <test_syscall@plt>
mov    0x2e5b(%rip),%rax
mov    (%rax),%edi
or     $0x30,%edi
call   1040 <test_syscall@plt>
mov    0x2e22(%rip),%rax
or     (%rax),%ebx
mov    %ebx,%edi
call   1040 <test_syscall@plt>
mov    0x2e1a(%rip),%rax
mov    (%rax),%edi
or     $0x14,%edi
call   1040 <test_syscall@plt>
mov    0x2e19(%rip),%rax
movzwl (%rax),%edi
xor    $0xffff,%edi
mov    0x2e01(%rip),%rax
or     (%rax),%edi
call   1040 <test_syscall@plt>
lea    0xe2b(%rip),%rdi
call   1030 <puts@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@S_IFREG = global i32 0
@S_IFDIR = global i32 0
@S_IFLNK = global i32 0
@S_IFIFO = global i32 0
@S_IFCHR = global i32 0
@S_IFMT = global i32 0
@S_IFBLK = global i32 0
@.str = [22 x i8] c"+++ exited with 0 +++\00"
define i32 @main() {
%1 = alloca i32
store i32 0, i32* %1
%2 = call i32 @test_syscall(i32 0)
%3 = call i32 @test_syscall(i32 65535)
%4 = call i32 @test_syscall(i32 6)
%5 = call i32 @test_syscall(i32 48)
%6 = call i32 @test_syscall(i32 384)
%7 = call i32 @test_syscall(i32 20)
%8 = load i32, i32* @S_IFREG
%9 = call i32 @test_syscall(i32 %8)
%10 = load i32, i32* @S_IFDIR
%11 = or i32 %10, 6
%12 = call i32 @test_syscall(i32 %11)
%13 = load i32, i32* @S_IFLNK
%14 = or i32 %13, 48
%15 = call i32 @test_syscall(i32 %14)
%16 = load i32, i32* @S_IFIFO
%17 = or i32 %16, 384
%18 = call i32 @test_syscall(i32 %17)
%19 = load i32, i32* @S_IFCHR
%20 = or i32 %19, 20
%21 = call i32 @test_syscall(i32 %20)
%22 = load i32, i32* @S_IFMT
%23 = xor i32 %22, -1
%24 = and i32 65535, %23
%25 = load i32, i32* @S_IFBLK
%26 = or i32 %24, %25
%27 = call i32 @test_syscall(i32 %26)
%28 = call i32 @puts(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
@S_IFREG = global i32 0
@S_IFDIR = global i32 0
@S_IFLNK = global i32 0
@S_IFIFO = global i32 0
@S_IFCHR = global i32 0
@S_IFMT = global i32 0
@S_IFBLK = global i32 0
@.str = [22 x i8] c"+++ exited with 0 +++\00"
define i32 @main() {
%1 = tail call i32 @test_syscall(i32 0)
%2 = tail call i32 @test_syscall(i32 65535)
%3 = tail call i32 @test_syscall(i32 6)
%4 = tail call i32 @test_syscall(i32 48)
%5 = tail call i32 @test_syscall(i32 384)
%6 = tail call i32 @test_syscall(i32 20)
%7 = load i32, i32* @S_IFREG
%8 = tail call i32 @test_syscall(i32 %7)
%9 = load i32, i32* @S_IFDIR
%10 = or i32 %9, 6
%11 = tail call i32 @test_syscall(i32 %10)
%12 = load i32, i32* @S_IFLNK
%13 = or i32 %12, 48
%14 = tail call i32 @test_syscall(i32 %13)
%15 = load i32, i32* @S_IFIFO
%16 = or i32 %15, 384
%17 = tail call i32 @test_syscall(i32 %16)
%18 = load i32, i32* @S_IFCHR
%19 = or i32 %18, 20
%20 = tail call i32 @test_syscall(i32 %19)
%21 = load i32, i32* @S_IFMT
%22 = and i32 %21, 65535
%23 = xor i32 %22, 65535
%24 = load i32, i32* @S_IFBLK
%25 = or i32 %23, %24
%26 = tail call i32 @test_syscall(i32 %25)
%27 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str, i64 0, i64 0))
ret i32 0
}