#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 EINTR;
int /*<<< orphan*/ F_GETFL;
int /*<<< orphan*/ F_SETFL;
int O_NONBLOCK;
int errno;
int /*<<< orphan*/ exit(int);
int fcntl(int, int /*<<< orphan*/, ...);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, char *, int);
int /*<<< orphan*/ stderr;
char *strerror(int);
void setNonBlocking(int fd) {
  int flags, ret, e;
  do {
    flags = fcntl(fd, F_GETFL);
  } while (flags == -1 && errno == EINTR);
  if (flags == -1) {
    e = errno;
    fprintf(stderr,
            "*** TempDirToucher error"
            ": cannot set pipe to non-blocking mode: "
            "cannot get file descriptor flags. Error: %s (errno %d)\n",
            strerror(e), e);
    exit(1);
  }
  do {
    ret = fcntl(fd, F_SETFL, flags | O_NONBLOCK);
  } while (ret == -1 && errno == EINTR);
  if (ret == -1) {
    e = errno;
    fprintf(stderr,
            "*** TempDirToucher error"
            ": cannot set pipe to non-blocking mode: "
            "cannot set file descriptor flags. Error: %s (errno %d)\n",
            strerror(e), e);
    exit(1);
  }
}


x86 assembly (clang, -O0):
<setNonBlocking>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%edi
mov    0x2e6b(%rip),%rax
mov    (%rax),%esi
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,-0x8(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0x8(%rbp)
mov    %al,-0x11(%rbp)
jne    1188 <setNonBlocking+0x48>
mov    0x2e51(%rip),%rax
mov    (%rax),%eax
mov    0x2e38(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    114b <setNonBlocking+0xb>
cmpl   $0xffffffff,-0x8(%rbp)
jne    11dc <setNonBlocking+0x9c>
mov    0x2e24(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2e28(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x18(%rbp),%edi
mov    %rax,%rdx
mov    -0x10(%rbp),%ecx
lea    0xe33(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
jmp    11e1 <setNonBlocking+0xa1>
mov    -0x4(%rbp),%edi
mov    0x2de5(%rip),%rax
mov    (%rax),%esi
mov    -0x8(%rbp),%edx
mov    0x2df1(%rip),%rax
or     (%rax),%edx
mov    $0x0,%al
call   1030 <fcntl@plt>
mov    %eax,-0xc(%rbp)
xor    %eax,%eax
cmpl   $0xffffffff,-0xc(%rbp)
mov    %al,-0x19(%rbp)
jne    122a <setNonBlocking+0xea>
mov    0x2daf(%rip),%rax
mov    (%rax),%eax
mov    0x2d96(%rip),%rcx
cmp    (%rcx),%eax
sete   %al
mov    %al,-0x19(%rbp)
mov    -0x19(%rbp),%al
test   $0x1,%al
jne    11e1 <setNonBlocking+0xa1>
cmpl   $0xffffffff,-0xc(%rbp)
jne    127e <setNonBlocking+0x13e>
mov    0x2d82(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x10(%rbp)
mov    0x2d86(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x20(%rbp)
mov    -0x10(%rbp),%edi
call   1060 <strerror@plt>
mov    -0x20(%rbp),%edi
mov    %rax,%rdx
mov    -0x10(%rbp),%ecx
lea    0xe09(%rip),%rsi
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setNonBlocking>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r14d
mov    0x2e6b(%rip),%r13
mov    0x2e6c(%rip),%r15
mov    0x2e55(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    0x0(%r13),%esi
mov    %r14d,%edi
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    %eax,%ebp
mov    (%r15),%ebx
cmp    $0xffffffff,%eax
jne    118e <setNonBlocking+0x4e>
cmp    (%r12),%ebx
je     1170 <setNonBlocking+0x30>
cmp    $0xffffffff,%ebp
je     11db <setNonBlocking+0x9b>
mov    0x2e4e(%rip),%r13
nopw   0x0(%rax,%rax,1)
mov    0x2e29(%rip),%rax
mov    (%rax),%esi
mov    0x0(%r13),%edx
or     %ebp,%edx
mov    %r14d,%edi
xor    %eax,%eax
call   1030 <fcntl@plt>
mov    (%r15),%ebx
cmp    $0xffffffff,%eax
jne    11c7 <setNonBlocking+0x87>
cmp    (%r12),%ebx
je     11a0 <setNonBlocking+0x60>
cmp    $0xffffffff,%eax
je     11f4 <setNonBlocking+0xb4>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2df6(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   1060 <strerror@plt>
lea    0xe0e(%rip),%rsi
jmp    120b <setNonBlocking+0xcb>
mov    0x2ddd(%rip),%rax
mov    (%rax),%ebp
mov    %ebx,%edi
call   1060 <strerror@plt>
lea    0xe6d(%rip),%rsi
mov    %ebp,%edi
mov    %rax,%rdx
mov    %ebx,%ecx
call   1040 <fprintf@plt>
mov    $0x1,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@F_GETFL = global i32 0
@errno = global i32 0
@EINTR = global i32 0
@stderr = global i32 0
@.str = [120 x i8] c"*** TempDirToucher error: cannot set pipe to non-blocking mode: cannot get file descriptor flags. Error: %s (errno %d)\0A\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [120 x i8] c"*** TempDirToucher error: cannot set pipe to non-blocking mode: cannot set file descriptor flags. Error: %s (errno %d)\0A\00"
define void @setNonBlocking(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 %0, i32* %2
br label %6
6: ; preds = %17, %1
%7 = load i32, i32* %2
%8 = load i32, i32* @F_GETFL
%9 = call i32 (i32, i32, ...) @fcntl(i32 %7, i32 %8)
store i32 %9, i32* %3
br label %10
10: ; preds = %6
%11 = load i32, i32* %3
%12 = icmp eq i32 %11, -1
br i1 %12, label %13, label %17
13: ; preds = %10
%14 = load i32, i32* @errno
%15 = load i32, i32* @EINTR
%16 = icmp eq i32 %14, %15
br label %17
17: ; preds = %13, %10
%18 = phi i1 [ false, %10 ], [ %16, %13 ]
br i1 %18, label %6, label %19
19: ; preds = %17
%20 = load i32, i32* %3
%21 = icmp eq i32 %20, -1
br i1 %21, label %22, label %30
22: ; preds = %19
%23 = load i32, i32* @errno
store i32 %23, i32* %5
%24 = load i32, i32* @stderr
%25 = load i32, i32* %5
%26 = call i8* @strerror(i32 %25)
%27 = load i32, i32* %5
%28 = call i32 @fprintf(i32 %24, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str, i64 0, i64 0), i8* %26, i32 %27)
%29 = call i32 @exit(i32 1)
unreachable
30: ; preds = %19
br label %31
31: ; preds = %45, %30
%32 = load i32, i32* %2
%33 = load i32, i32* @F_SETFL
%34 = load i32, i32* %3
%35 = load i32, i32* @O_NONBLOCK
%36 = or i32 %34, %35
%37 = call i32 (i32, i32, ...) @fcntl(i32 %32, i32 %33, i32 %36)
store i32 %37, i32* %4
br label %38
38: ; preds = %31
%39 = load i32, i32* %4
%40 = icmp eq i32 %39, -1
br i1 %40, label %41, label %45
41: ; preds = %38
%42 = load i32, i32* @errno
%43 = load i32, i32* @EINTR
%44 = icmp eq i32 %42, %43
br label %45
45: ; preds = %41, %38
%46 = phi i1 [ false, %38 ], [ %44, %41 ]
br i1 %46, label %31, label %47
47: ; preds = %45
%48 = load i32, i32* %4
%49 = icmp eq i32 %48, -1
br i1 %49, label %50, label %58
50: ; preds = %47
%51 = load i32, i32* @errno
store i32 %51, i32* %5
%52 = load i32, i32* @stderr
%53 = load i32, i32* %5
%54 = call i8* @strerror(i32 %53)
%55 = load i32, i32* %5
%56 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.1, i64 0, i64 0), i8* %54, i32 %55)
%57 = call i32 @exit(i32 1)
unreachable
58: ; preds = %47
ret void
}

LLVM IR (-O2):
@F_GETFL = global i32 0
@errno = global i32 0
@EINTR = global i32 0
@stderr = global i32 0
@.str = [120 x i8] c"*** TempDirToucher error: cannot set pipe to non-blocking mode: cannot get file descriptor flags. Error: %s (errno %d)\0A\00"
@F_SETFL = global i32 0
@O_NONBLOCK = global i32 0
@.str.1 = [120 x i8] c"*** TempDirToucher error: cannot set pipe to non-blocking mode: cannot set file descriptor flags. Error: %s (errno %d)\0A\00"
define void @setNonBlocking(i32 %0) {
br label %2
2: ; preds = %2, %1
%3 = load i32, i32* @F_GETFL
%4 = tail call i32 (i32, i32, ...) @fcntl(i32 %0, i32 %3)
%5 = icmp eq i32 %4, -1
%6 = load i32, i32* @errno
%7 = load i32, i32* @EINTR
%8 = icmp eq i32 %6, %7
%9 = select i1 %5, i1 %8, i1 false
br i1 %9, label %2, label %10
10: ; preds = %2
br i1 %5, label %11, label %16
11: ; preds = %10
%12 = load i32, i32* @stderr
%13 = tail call i8* @strerror(i32 %6)
%14 = tail call i32 @fprintf(i32 %12, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str, i64 0, i64 0), i8* %13, i32 %6)
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %10, %16
%17 = load i32, i32* @F_SETFL
%18 = load i32, i32* @O_NONBLOCK
%19 = or i32 %18, %4
%20 = tail call i32 (i32, i32, ...) @fcntl(i32 %0, i32 %17, i32 %19)
%21 = icmp eq i32 %20, -1
%22 = load i32, i32* @errno
%23 = load i32, i32* @EINTR
%24 = icmp eq i32 %22, %23
%25 = select i1 %21, i1 %24, i1 false
br i1 %25, label %16, label %26
26: ; preds = %16
br i1 %21, label %27, label %32
27: ; preds = %26
%28 = load i32, i32* @stderr
%29 = tail call i8* @strerror(i32 %22)
%30 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([120 x i8], [120 x i8]* @.str.1, i64 0, i64 0), i8* %29, i32 %22)
%31 = tail call i32 @exit(i32 1)
unreachable
32: ; preds = %26
ret void
}