#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 EBADF;
int errno;
int nice(int const);
int /*<<< orphan*/ printf(char *, int const, int const, ...);
int do_test(void) {
  int ret;
  const int incr = 10;
  int old;
  errno = 0;
  old = nice(0);
  if (old == -1 && errno != 0) {
    printf("break: nice(%d) return: %d, %m\n", 0, old);
    return 1;
  }
  errno = 0;
  ret = nice(incr);
  if (ret == -1 && errno != 0) {
    printf("break: nice(%d) return: %d, %m\n", incr, ret);
    return 1;
  }
  if (ret <= old) {
    printf("FAIL: retval (%d) of nice(%d) != %d\n", ret, incr, old + incr);
    return 1;
  }
  errno = EBADF;
  nice(0);
  if (errno != EBADF) {
    printf("FAIL: errno = %i, but wanted EBADF (%i)\n", errno, EBADF);
    return 1;
  }
  printf("PASS: nice(%d) from %d return: %d\n", incr, old, ret);
  return 0;
}


x86 assembly (clang, -O0):
<do_test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0xa,-0xc(%rbp)
mov    0x2eaa(%rip),%rax
movl   $0x0,(%rax)
xor    %edi,%edi
call   1040 <nice@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    117f <do_test+0x5f>
mov    0x2e89(%rip),%rax
cmpl   $0x0,(%rax)
je     117f <do_test+0x5f>
mov    -0x10(%rbp),%edx
lea    0xe96(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1286 <do_test+0x166>
mov    0x2e5a(%rip),%rax
movl   $0x0,(%rax)
mov    $0xa,%edi
call   1040 <nice@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    11d5 <do_test+0xb5>
mov    0x2e36(%rip),%rax
cmpl   $0x0,(%rax)
je     11d5 <do_test+0xb5>
mov    -0x8(%rbp),%edx
lea    0xe43(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1286 <do_test+0x166>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     1209 <do_test+0xe9>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%ecx
add    $0xa,%ecx
lea    0xe2f(%rip),%rdi
mov    $0xa,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1286 <do_test+0x166>
mov    0x2dc8(%rip),%rax
mov    (%rax),%ecx
mov    0x2dc7(%rip),%rax
mov    %ecx,(%rax)
xor    %edi,%edi
call   1040 <nice@plt>
mov    0x2db7(%rip),%rax
mov    (%rax),%eax
mov    0x2da6(%rip),%rcx
cmp    (%rcx),%eax
je     1266 <do_test+0x146>
mov    0x2d9f(%rip),%rax
mov    (%rax),%esi
mov    0x2d8e(%rip),%rax
mov    (%rax),%edx
lea    0xdf2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1286 <do_test+0x166>
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xdfb(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<do_test>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    0x2eb1(%rip),%r15
movl   $0x0,(%r15)
xor    %edi,%edi
call   1040 <nice@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1155 <do_test+0x35>
cmpl   $0x0,(%r15)
je     1155 <do_test+0x35>
lea    0xeaf(%rip),%rdi
xor    %esi,%esi
jmp    1180 <do_test+0x60>
movl   $0x0,(%r15)
mov    $0xa,%edi
call   1040 <nice@plt>
mov    %eax,%r14d
cmp    $0xffffffff,%eax
jne    119c <do_test+0x7c>
cmpl   $0x0,(%r15)
je     119c <do_test+0x7c>
lea    0xe85(%rip),%rdi
mov    $0xa,%esi
mov    $0xffffffff,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
cmp    %ebx,%r14d
jle    11dd <do_test+0xbd>
mov    0x2e30(%rip),%r12
mov    (%r12),%eax
mov    %eax,(%r15)
xor    %ebp,%ebp
xor    %edi,%edi
call   1040 <nice@plt>
mov    (%r15),%esi
mov    (%r12),%edx
cmp    %edx,%esi
jne    11fa <do_test+0xda>
lea    0xea4(%rip),%rdi
mov    $0xa,%esi
mov    %ebx,%edx
mov    %r14d,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1191 <do_test+0x71>
add    $0xa,%ebx
lea    0xe39(%rip),%rdi
mov    %r14d,%esi
mov    $0xa,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    118c <do_test+0x6c>
lea    0xe44(%rip),%rdi
jmp    1185 <do_test+0x65>

LLVM IR (-O0):
@errno = global i32 0
@.str = [32 x i8] c"break: nice(%d) return: %d, %m\0A\00"
@.str.1 = [37 x i8] c"FAIL: retval (%d) of nice(%d) != %d\0A\00"
@EBADF = global i32 0
@.str.2 = [41 x i8] c"FAIL: errno = %i, but wanted EBADF (%i)\0A\00"
@.str.3 = [35 x i8] c"PASS: nice(%d) from %d return: %d\0A\00"
define i32 @do_test() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 10, i32* %3
store i32 0, i32* @errno
%5 = call i32 @nice(i32 0)
store i32 %5, i32* %4
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, -1
br i1 %7, label %8, label %14
8: ; preds = %0
%9 = load i32, i32* @errno
%10 = icmp ne i32 %9, 0
br i1 %10, label %11, label %14
11: ; preds = %8
%12 = load i32, i32* %4
%13 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 0, i32 %12)
store i32 1, i32* %1
br label %47
14: ; preds = %8, %0
store i32 0, i32* @errno
%15 = call i32 @nice(i32 10)
store i32 %15, i32* %2
%16 = load i32, i32* %2
%17 = icmp eq i32 %16, -1
br i1 %17, label %18, label %24
18: ; preds = %14
%19 = load i32, i32* @errno
%20 = icmp ne i32 %19, 0
br i1 %20, label %21, label %24
21: ; preds = %18
%22 = load i32, i32* %2
%23 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 10, i32 %22)
store i32 1, i32* %1
br label %47
24: ; preds = %18, %14
%25 = load i32, i32* %2
%26 = load i32, i32* %4
%27 = icmp sle i32 %25, %26
br i1 %27, label %28, label %33
28: ; preds = %24
%29 = load i32, i32* %2
%30 = load i32, i32* %4
%31 = add nsw i32 %30, 10
%32 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %29, i32 10, i32 %31)
store i32 1, i32* %1
br label %47
33: ; preds = %24
%34 = load i32, i32* @EBADF
store i32 %34, i32* @errno
%35 = call i32 @nice(i32 0)
%36 = load i32, i32* @errno
%37 = load i32, i32* @EBADF
%38 = icmp ne i32 %36, %37
br i1 %38, label %39, label %43
39: ; preds = %33
%40 = load i32, i32* @errno
%41 = load i32, i32* @EBADF
%42 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %40, i32 %41)
store i32 1, i32* %1
br label %47
43: ; preds = %33
%44 = load i32, i32* %4
%45 = load i32, i32* %2
%46 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 10, i32 %44, i32 %45)
store i32 0, i32* %1
br label %47
47: ; preds = %43, %39, %28, %21, %11
%48 = load i32, i32* %1
ret i32 %48
}

LLVM IR (-O2):
@errno = global i32 0
@.str = [32 x i8] c"break: nice(%d) return: %d, %m\0A\00"
@.str.1 = [37 x i8] c"FAIL: retval (%d) of nice(%d) != %d\0A\00"
@EBADF = global i32 0
@.str.2 = [41 x i8] c"FAIL: errno = %i, but wanted EBADF (%i)\0A\00"
@.str.3 = [35 x i8] c"PASS: nice(%d) from %d return: %d\0A\00"
define i32 @do_test() {
store i32 0, i32* @errno
%1 = tail call i32 @nice(i32 0)
%2 = icmp eq i32 %1, -1
%3 = load i32, i32* @errno
%4 = icmp ne i32 %3, 0
%5 = select i1 %2, i1 %4, i1 false
br i1 %5, label %6, label %8
6: ; preds = %0
%7 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 0, i32 -1)
br label %31
8: ; preds = %0
store i32 0, i32* @errno
%9 = tail call i32 @nice(i32 10)
%10 = icmp eq i32 %9, -1
%11 = load i32, i32* @errno
%12 = icmp ne i32 %11, 0
%13 = select i1 %10, i1 %12, i1 false
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str, i64 0, i64 0), i32 10, i32 -1)
br label %31
16: ; preds = %8
%17 = icmp sgt i32 %9, %1
br i1 %17, label %21, label %18
18: ; preds = %16
%19 = add nsw i32 %1, 10
%20 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i32 %9, i32 10, i32 %19)
br label %31
21: ; preds = %16
%22 = load i32, i32* @EBADF
store i32 %22, i32* @errno
%23 = tail call i32 @nice(i32 0)
%24 = load i32, i32* @errno
%25 = load i32, i32* @EBADF
%26 = icmp eq i32 %24, %25
br i1 %26, label %29, label %27
27: ; preds = %21
%28 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([41 x i8], [41 x i8]* @.str.2, i64 0, i64 0), i32 %24, i32 %25)
br label %31
29: ; preds = %21
%30 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0), i32 10, i32 %1, i32 %9)
br label %31
31: ; preds = %29, %27, %18, %14, %6
%32 = phi i32 [ 1, %6 ], [ 1, %14 ], [ 1, %18 ], [ 1, %27 ], [ 0, %29 ]
ret i32 %32
}