#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 */
char *getenv(char *);
int /*<<< orphan*/ log_stderr(char *, char *);
int /*<<< orphan*/ log_stdout(char *, int);
int nice(int);
int /*<<< orphan*/ perror(char *);
int strtol(char *, char **, int);
void renice() {
  char *nicestr = getenv("DUCC_NICE");
  int niceval = 10;
  if (nicestr != NULL) {
    char *en = 0;
    niceval = strtol(nicestr, &en, 10);
    if (*en) {
      log_stderr("4070 NICE: %s is not numeric; nice not set.\n", nicestr);
      return;
    }
  }
  log_stdout("4050 Nice: Using %d\n", niceval);
  int rc = nice(niceval);
  if (rc < 0) {
    perror("4060 Can't set nice.");
  }
}


x86 assembly (clang, -O0):
<renice>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xe91(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
movl   $0xa,-0xc(%rbp)
cmpq   $0x0,-0x8(%rbp)
je     11ce <renice+0x6e>
movq   $0x0,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
lea    -0x18(%rbp),%rsi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,-0xc(%rbp)
mov    -0x18(%rbp),%rax
cmpb   $0x0,(%rax)
je     11c9 <renice+0x69>
mov    -0x8(%rbp),%rsi
lea    0xe4b(%rip),%rdi
call   1040 <log_stderr@plt>
jmp    11fe <renice+0x9e>
jmp    11ce <renice+0x6e>
mov    -0xc(%rbp),%esi
lea    0xe5f(%rip),%rdi
call   1070 <log_stdout@plt>
mov    -0xc(%rbp),%edi
call   1060 <nice@plt>
mov    %eax,-0x1c(%rbp)
cmpl   $0x0,-0x1c(%rbp)
jge    11fe <renice+0x9e>
lea    0xe53(%rip),%rdi
call   1080 <perror@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<renice>:
push   %rbp
push   %rbx
push   %rax
lea    0xe96(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     11ab <renice+0x4b>
mov    %rax,%rbx
movq   $0x0,(%rsp)
mov    %rsp,%rsi
mov    %rax,%rdi
mov    $0xa,%edx
call   1050 <strtol@plt>
mov    %eax,%ebp
mov    (%rsp),%rax
cmpb   $0x0,(%rax)
je     11b0 <renice+0x50>
lea    0xe69(%rip),%rdi
mov    %rbx,%rsi
call   1040 <log_stderr@plt>
jmp    11c9 <renice+0x69>
mov    $0xa,%ebp
lea    0xe80(%rip),%rdi
mov    %ebp,%esi
call   1070 <log_stdout@plt>
mov    %ebp,%edi
call   1060 <nice@plt>
test   %eax,%eax
js     11d0 <renice+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe75(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1080 <perror@plt>

LLVM IR (-O0):
@.str = [10 x i8] c"DUCC_NICE\00"
@.str.1 = [45 x i8] c"4070 NICE: %s is not numeric; nice not set.\0A\00"
@.str.2 = [21 x i8] c"4050 Nice: Using %d\0A\00"
@.str.3 = [21 x i8] c"4060 Can't set nice.\00"
define void @renice() {
%1 = alloca i8*
%2 = alloca i32
%3 = alloca i8*
%4 = alloca i32
%5 = call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
store i8* %5, i8** %1
store i32 10, i32* %2
%6 = load i8*, i8** %1
%7 = icmp ne i8* %6, null
br i1 %7, label %8, label %18
8: ; preds = %0
store i8* null, i8** %3
%9 = load i8*, i8** %1
%10 = call i32 @strtol(i8* %9, i8** %3, i32 10)
store i32 %10, i32* %2
%11 = load i8*, i8** %3
%12 = load i8, i8* %11
%13 = icmp ne i8 %12, 0
br i1 %13, label %14, label %17
14: ; preds = %8
%15 = load i8*, i8** %1
%16 = call i32 @log_stderr(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %15)
br label %27
17: ; preds = %8
br label %18
18: ; preds = %17, %0
%19 = load i32, i32* %2
%20 = call i32 @log_stdout(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %19)
%21 = load i32, i32* %2
%22 = call i32 @nice(i32 %21)
store i32 %22, i32* %4
%23 = load i32, i32* %4
%24 = icmp slt i32 %23, 0
br i1 %24, label %25, label %27
25: ; preds = %18
%26 = call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %27
27: ; preds = %14, %25, %18
ret void
}

LLVM IR (-O2):
@.str = [10 x i8] c"DUCC_NICE\00"
@.str.1 = [45 x i8] c"4070 NICE: %s is not numeric; nice not set.\0A\00"
@.str.2 = [21 x i8] c"4050 Nice: Using %d\0A\00"
@.str.3 = [21 x i8] c"4060 Can't set nice.\00"
define void @renice() {
%1 = alloca i8*
%2 = tail call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0))
%3 = icmp eq i8* %2, null
br i1 %3, label %13, label %4
4: ; preds = %0
%5 = bitcast i8** %1 to i8*
store i8* null, i8** %1
%6 = call i32 @strtol(i8* %2, i8** %1, i32 10)
%7 = load i8*, i8** %1
%8 = load i8, i8* %7
%9 = icmp eq i8 %8, 0
br i1 %9, label %12, label %10
10: ; preds = %4
%11 = tail call i32 @log_stderr(i8* getelementptr inbounds ([45 x i8], [45 x i8]* @.str.1, i64 0, i64 0), i8* %2)
br label %20
12: ; preds = %4
br label %13
13: ; preds = %12, %0
%14 = phi i32 [ 10, %0 ], [ %6, %12 ]
%15 = tail call i32 @log_stdout(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0), i32 %14)
%16 = tail call i32 @nice(i32 %14)
%17 = icmp slt i32 %16, 0
br i1 %17, label %18, label %20
18: ; preds = %13
%19 = tail call i32 @perror(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
br label %20
20: ; preds = %10, %13, %18
ret void
}