#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 */
typedef int pid_t;

/* Variables and functions */
int myniceset(int, int, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, int *);
int main() {
  pid_t pid;
  int flag, nicevalue = 0, res = 0;
  printf("请依次输入pid和flag，若flag为1则需要输入要设置的nice值：\n");
  scanf("%d", &pid);
  scanf("%d", &flag);
  if (flag == 1) {
    scanf("%d", &nicevalue);
    res = myniceset(pid, flag, nicevalue);
  } else {
    res = myniceset(pid, flag);
  }
  printf("\n%d\n", res);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xeac(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeec(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
lea    0xedc(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1040 <scanf@plt>
cmpl   $0x1,-0xc(%rbp)
jne    11ad <main+0x7d>
lea    0xec2(%rip),%rdi
lea    -0x10(%rbp),%rsi
call   1040 <scanf@plt>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    -0x10(%rbp),%edx
mov    $0x0,%al
call   1050 <myniceset@plt>
mov    %eax,-0x14(%rbp)
jmp    11bd <main+0x8d>
mov    -0x8(%rbp),%edi
mov    -0xc(%rbp),%esi
mov    $0x0,%al
call   1050 <myniceset@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
lea    0xe8a(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
movl   $0x0,0x4(%rsp)
lea    0xeb4(%rip),%rdi
call   1030 <puts@plt>
lea    0xea0(%rip),%rbx
lea    0xc(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
lea    0x8(%rsp),%rsi
mov    %rbx,%rdi
call   1050 <scanf@plt>
mov    0x8(%rsp),%esi
cmp    $0x1,%esi
jne    11a9 <main+0x69>
lea    0xe76(%rip),%rdi
lea    0x4(%rsp),%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edi
mov    0x8(%rsp),%esi
mov    0x4(%rsp),%edx
xor    %eax,%eax
call   1060 <myniceset@plt>
jmp    11b4 <main+0x74>
mov    0xc(%rsp),%edi
xor    %eax,%eax
call   1060 <myniceset@plt>
lea    0xe48(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [78 x i8] c"\E8\AF\B7\E4\BE\9D\E6\AC\A1\E8\BE\93\E5\85\A5pid\E5\92\8Cflag\EF\BC\8C\E8\8B\A5flag\E4\B8\BA1\E5\88\99\E9\9C\80\E8\A6\81\E8\BE\93\E5\85\A5\E8\A6\81\E8\AE\BE\E7\BD\AE\E7\9A\84nice\E5\80\BC\EF\BC\9A\0A\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"\0A%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %4
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([78 x i8], [78 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%9 = load i32, i32* %3
%10 = icmp eq i32 %9, 1
br i1 %10, label %11, label %17
11: ; preds = %0
%12 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%13 = load i32, i32* %2
%14 = load i32, i32* %3
%15 = load i32, i32* %4
%16 = call i32 (i32, i32, ...) @myniceset(i32 %13, i32 %14, i32 %15)
store i32 %16, i32* %5
br label %21
17: ; preds = %0
%18 = load i32, i32* %2
%19 = load i32, i32* %3
%20 = call i32 (i32, i32, ...) @myniceset(i32 %18, i32 %19)
store i32 %20, i32* %5
br label %21
21: ; preds = %17, %11
%22 = load i32, i32* %5
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %22)
ret i32 0
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [5 x i8] c"\0A%d\0A\00"
@str = [77 x i8] c"\E8\AF\B7\E4\BE\9D\E6\AC\A1\E8\BE\93\E5\85\A5pid\E5\92\8Cflag\EF\BC\8C\E8\8B\A5flag\E4\B8\BA1\E5\88\99\E9\9C\80\E8\A6\81\E8\BE\93\E5\85\A5\E8\A6\81\E8\AE\BE\E7\BD\AE\E7\9A\84nice\E5\80\BC\EF\BC\9A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = bitcast i32* %2 to i8*
%6 = bitcast i32* %3 to i8*
store i32 0, i32* %3
%7 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([77 x i8], [77 x i8]* @str, i64 0, i64 0))
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
%9 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
%10 = load i32, i32* %2
%11 = icmp eq i32 %10, 1
br i1 %11, label %12, label %18
12: ; preds = %0
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%14 = load i32, i32* %1
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = call i32 (i32, i32, ...) @myniceset(i32 %14, i32 %15, i32 %16)
br label %21
18: ; preds = %0
%19 = load i32, i32* %1
%20 = call i32 (i32, i32, ...) @myniceset(i32 %19, i32 %10)
br label %21
21: ; preds = %18, %12
%22 = phi i32 [ %17, %12 ], [ %20, %18 ]
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i32 %22)
ret i32 0
}