#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 */
typedef int mode_t;

/* Variables and functions */
int S_IRGRP;
int S_IROTH;
int S_IRUSR;
int S_IWUSR;
int /*<<< orphan*/ close(int);
int creat(char *, int);
int /*<<< orphan*/ perror(char *);
int t02(void) {
  mode_t mode = S_IRUSR | S_IWUSR | S_IRGRP | S_IROTH;
  int fd;
  fd = creat("/tmp/fi/le1", mode);
  if (fd == -1) {
    perror("creat");
    return 1;
  }
  close(fd);
  return 0;
}


x86 assembly (clang, -O0):
<t02>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    0x2e89(%rip),%rax
mov    (%rax),%eax
mov    0x2ea0(%rip),%rcx
or     (%rcx),%eax
mov    0x2e87(%rip),%rcx
or     (%rcx),%eax
mov    0x2e76(%rip),%rcx
or     (%rcx),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
lea    0xe97(%rip),%rdi
call   1050 <creat@plt>
mov    %eax,-0xc(%rbp)
cmpl   $0xffffffff,-0xc(%rbp)
jne    1193 <t02+0x63>
lea    0xe8a(%rip),%rdi
call   1040 <perror@plt>
movl   $0x1,-0x4(%rbp)
jmp    11a2 <t02+0x72>
mov    -0xc(%rbp),%edi
call   1030 <close@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<t02>:
push   %rax
mov    0x2e90(%rip),%rax
mov    0x2ea9(%rip),%rcx
mov    (%rcx),%esi
or     (%rax),%esi
mov    0x2e8e(%rip),%rax
or     (%rax),%esi
mov    0x2e7d(%rip),%rax
or     (%rax),%esi
lea    0xea4(%rip),%rdi
call   1050 <creat@plt>
cmp    $0xffffffff,%eax
je     1171 <t02+0x41>
mov    %eax,%edi
call   1030 <close@plt>
xor    %eax,%eax
pop    %rcx
ret
lea    0xe94(%rip),%rdi
call   1040 <perror@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@.str = [12 x i8] c"/tmp/fi/le1\00"
@.str.1 = [6 x i8] c"creat\00"
define i32 @t02() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = load i32, i32* @S_IRUSR
%5 = load i32, i32* @S_IWUSR
%6 = or i32 %4, %5
%7 = load i32, i32* @S_IRGRP
%8 = or i32 %6, %7
%9 = load i32, i32* @S_IROTH
%10 = or i32 %8, %9
store i32 %10, i32* %2
%11 = load i32, i32* %2
%12 = call i32 @creat(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 %12, i32* %3
%13 = load i32, i32* %3
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %0
%16 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
store i32 1, i32* %1
br label %20
17: ; preds = %0
%18 = load i32, i32* %3
%19 = call i32 @close(i32 %18)
store i32 0, i32* %1
br label %20
20: ; preds = %17, %15
%21 = load i32, i32* %1
ret i32 %21
}

LLVM IR (-O2):
@S_IRUSR = global i32 0
@S_IWUSR = global i32 0
@S_IRGRP = global i32 0
@S_IROTH = global i32 0
@.str = [12 x i8] c"/tmp/fi/le1\00"
@.str.1 = [6 x i8] c"creat\00"
define i32 @t02() {
%1 = load i32, i32* @S_IRUSR
%2 = load i32, i32* @S_IWUSR
%3 = or i32 %2, %1
%4 = load i32, i32* @S_IRGRP
%5 = or i32 %3, %4
%6 = load i32, i32* @S_IROTH
%7 = or i32 %5, %6
%8 = tail call i32 @creat(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %7)
%9 = icmp eq i32 %8, -1
br i1 %9, label %10, label %12
10: ; preds = %0
%11 = tail call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
br label %14
12: ; preds = %0
%13 = tail call i32 @close(i32 %8)
br label %14
14: ; preds = %12, %10
%15 = phi i32 [ 1, %10 ], [ 0, %12 ]
ret i32 %15
}