#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 */
scalar_t__ 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;
  }
  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
movq   $0x0,(%rax)
xor    %edi,%edi
call   1040 <nice@plt>
mov    %eax,-0x10(%rbp)
cmpl   $0xffffffff,-0x10(%rbp)
jne    1181 <do_test+0x61>
mov    0x2e88(%rip),%rax
cmpq   $0x0,(%rax)
je     1181 <do_test+0x61>
mov    -0x10(%rbp),%edx
lea    0xe94(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122d <do_test+0x10d>
mov    0x2e58(%rip),%rax
movq   $0x0,(%rax)
mov    $0xa,%edi
call   1040 <nice@plt>
mov    %eax,-0x8(%rbp)
cmpl   $0xffffffff,-0x8(%rbp)
jne    11d9 <do_test+0xb9>
mov    0x2e33(%rip),%rax
cmpq   $0x0,(%rax)
je     11d9 <do_test+0xb9>
mov    -0x8(%rbp),%edx
lea    0xe3f(%rip),%rdi
mov    $0xa,%esi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122d <do_test+0x10d>
mov    -0x8(%rbp),%eax
cmp    -0x10(%rbp),%eax
jg     120d <do_test+0xed>
mov    -0x8(%rbp),%esi
mov    -0x10(%rbp),%ecx
add    $0xa,%ecx
lea    0xe2b(%rip),%rdi
mov    $0xa,%edx
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    122d <do_test+0x10d>
mov    -0x10(%rbp),%edx
mov    -0x8(%rbp),%ecx
lea    0xe2b(%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   %rbx
push   %rax
mov    0x2eb6(%rip),%rbp
movq   $0x0,0x0(%rbp)
xor    %edi,%edi
call   1040 <nice@plt>
mov    %eax,%ebx
cmp    $0xffffffff,%eax
jne    1152 <do_test+0x32>
cmpq   $0x0,0x0(%rbp)
je     1152 <do_test+0x32>
lea    0xeb2(%rip),%rdi
xor    %esi,%esi
jmp    117c <do_test+0x5c>
movq   $0x0,0x0(%rbp)
mov    $0xa,%edi
call   1040 <nice@plt>
cmp    $0xffffffff,%eax
jne    1196 <do_test+0x76>
cmpq   $0x0,0x0(%rbp)
je     1196 <do_test+0x76>
lea    0xe89(%rip),%rdi
mov    $0xa,%esi
mov    $0xffffffff,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%ebp
mov    %ebp,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
cmp    %ebx,%eax
jle    11b5 <do_test+0x95>
lea    0xea4(%rip),%rdi
xor    %ebp,%ebp
mov    $0xa,%esi
mov    %ebx,%edx
mov    %eax,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    118d <do_test+0x6d>
add    $0xa,%ebx
lea    0xe61(%rip),%rdi
mov    %eax,%esi
mov    $0xa,%edx
mov    %ebx,%ecx
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1188 <do_test+0x68>

LLVM IR (-O0):
@errno = global i64 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"
@.str.2 = [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 i64 0, i64* @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 i64, i64* @errno
%10 = icmp ne i64 %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 %37
14: ; preds = %8, %0
store i64 0, i64* @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 i64, i64* @errno
%20 = icmp ne i64 %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 %37
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 %37
33: ; preds = %24
%34 = load i32, i32* %4
%35 = load i32, i32* %2
%36 = call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 10, i32 %34, i32 %35)
store i32 0, i32* %1
br label %37
37: ; preds = %33, %28, %21, %11
%38 = load i32, i32* %1
ret i32 %38
}

LLVM IR (-O2):
@errno = global i64 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"
@.str.2 = [35 x i8] c"PASS: nice(%d) from %d return: %d\0A\00"
define i32 @do_test() {
store i64 0, i64* @errno
%1 = tail call i32 @nice(i32 0)
%2 = icmp eq i32 %1, -1
%3 = load i64, i64* @errno
%4 = icmp ne i64 %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 %23
8: ; preds = %0
store i64 0, i64* @errno
%9 = tail call i32 @nice(i32 10)
%10 = icmp eq i32 %9, -1
%11 = load i64, i64* @errno
%12 = icmp ne i64 %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 %23
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 %23
21: ; preds = %16
%22 = tail call i32 (i8*, i32, i32, ...) @printf(i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.2, i64 0, i64 0), i32 10, i32 %1, i32 %9)
br label %23
23: ; preds = %21, %18, %14, %6
%24 = phi i32 [ 1, %6 ], [ 1, %14 ], [ 1, %18 ], [ 0, %21 ]
ret i32 %24
}