#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*/ O_RDONLY;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ grg_file_shred(char *, int);
int mkstemp(char *);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ write(int, char *, int);
int test9() {
  char name[] = "/tmp/libgrg-tmp-XXXXXX";
  int fd = mkstemp(name);
  if (fd < 0)
    return 1;
  write(fd, "hullo", 5);
  close(fd);
  grg_file_shred(name, 32);
  fd = open(name, O_RDONLY);
  if (fd < 0)
    return 0;
  return 1;
}


x86 assembly (clang, -O0):
<test9>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    0xea1(%rip),%rax
mov    %rax,-0x20(%rbp)
mov    0xe9e(%rip),%rax
mov    %rax,-0x18(%rbp)
mov    0xe9c(%rip),%eax
mov    %eax,-0x10(%rbp)
mov    0xe96(%rip),%ax
mov    %ax,-0xc(%rbp)
mov    0xe8e(%rip),%al
mov    %al,-0xa(%rbp)
lea    -0x20(%rbp),%rdi
call   1050 <mkstemp@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    11ad <test9+0x5d>
movl   $0x1,-0x4(%rbp)
jmp    1209 <test9+0xb9>
mov    -0x24(%rbp),%edi
lea    0xe60(%rip),%rsi
mov    $0x5,%edx
call   1030 <write@plt>
mov    -0x24(%rbp),%edi
call   1040 <close@plt>
lea    -0x20(%rbp),%rdi
mov    $0x20,%esi
call   1070 <grg_file_shred@plt>
lea    -0x20(%rbp),%rdi
mov    0x2e06(%rip),%rax
mov    (%rax),%esi
call   1060 <open@plt>
mov    %eax,-0x24(%rbp)
cmpl   $0x0,-0x24(%rbp)
jge    1202 <test9+0xb2>
movl   $0x0,-0x4(%rbp)
jmp    1209 <test9+0xb9>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test9>:
push   %rbx
sub    $0x20,%rsp
movaps 0xea4(%rip),%xmm0
movaps %xmm0,(%rsp)
movabs $0x5858585858582d,%rax
mov    %rax,0xf(%rsp)
mov    %rsp,%rdi
call   1050 <mkstemp@plt>
test   %eax,%eax
js     11bf <test9+0x6f>
mov    %eax,%ebx
lea    0xe93(%rip),%rsi
mov    %eax,%edi
mov    $0x5,%edx
call   1030 <write@plt>
mov    %ebx,%edi
call   1040 <close@plt>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x20,%esi
call   1070 <grg_file_shred@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%esi
mov    %rbx,%rdi
call   1060 <open@plt>
not    %eax
shr    $0x1f,%eax
jmp    11c4 <test9+0x74>
mov    $0x1,%eax
add    $0x20,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@__const.test9.name = [23 x i8] c"/tmp/libgrg-tmp-XXXXXX\00"
@.str = [6 x i8] c"hullo\00"
@O_RDONLY = global i32 0
define i32 @test9() {
%1 = alloca i32
%2 = alloca [23 x i8]
%3 = alloca i32
%4 = bitcast [23 x i8]* %2 to i8*
%5 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%6 = call i32 @mkstemp(i8* %5)
store i32 %6, i32* %3
%7 = load i32, i32* %3
%8 = icmp slt i32 %7, 0
br i1 %8, label %9, label %10
9: ; preds = %0
store i32 1, i32* %1
br label %24
10: ; preds = %0
%11 = load i32, i32* %3
%12 = call i32 @write(i32 %11, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%13 = load i32, i32* %3
%14 = call i32 @close(i32 %13)
%15 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%16 = call i32 @grg_file_shred(i8* %15, i32 32)
%17 = getelementptr inbounds [23 x i8], [23 x i8]* %2, i64 0, i64 0
%18 = load i32, i32* @O_RDONLY
%19 = call i32 @open(i8* %17, i32 %18)
store i32 %19, i32* %3
%20 = load i32, i32* %3
%21 = icmp slt i32 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %10
store i32 0, i32* %1
br label %24
23: ; preds = %10
store i32 1, i32* %1
br label %24
24: ; preds = %23, %22, %9
%25 = load i32, i32* %1
ret i32 %25
}

LLVM IR (-O2):
@__const.test9.name = [23 x i8] c"/tmp/libgrg-tmp-XXXXXX\00"
@.str = [6 x i8] c"hullo\00"
@O_RDONLY = global i32 0
define i32 @test9() {
%1 = alloca [23 x i8]
%2 = getelementptr inbounds [23 x i8], [23 x i8]* %1, i64 0, i64 0
%3 = call i32 @mkstemp(i8* %2)
%4 = icmp slt i32 %3, 0
br i1 %4, label %13, label %5
5: ; preds = %0
%6 = call i32 @write(i32 %3, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0), i32 5)
%7 = call i32 @close(i32 %3)
%8 = call i32 @grg_file_shred(i8* %2, i32 32)
%9 = load i32, i32* @O_RDONLY
%10 = call i32 @open(i8* %2, i32 %9)
%11 = xor i32 %10, -1
%12 = lshr i32 %11, 31
br label %13
13: ; preds = %5, %0
%14 = phi i32 [ 1, %0 ], [ %12, %5 ]
ret i32 %14
}