#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 scalar_t__ pid_t;

/* Variables and functions */
scalar_t__ atoi(char *);
int kill(scalar_t__);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ read(int /*<<< orphan*/, char *, int);
int main(int argc, char *argv[], char *envp[]) {
  char pids[5];
  pid_t pid;
  if (argc < 2) {
    printf("Enter a pid: ");
    read(0, pids, 5);
    pid = atoi(pids);
  } else {
    pid = atoi(argv[1]);
  }
  printf("pid: %d\n", (int)pid);
  int rv = kill(pid);
  printf("return: %d\n", rv);
  return rv;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1194 <main+0x54>
lea    0xe95(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x1d(%rbp),%rsi
xor    %edi,%edi
mov    $0x5,%edx
call   1040 <read@plt>
lea    -0x1d(%rbp),%rdi
call   1060 <atoi@plt>
mov    %rax,-0x28(%rbp)
jmp    11a5 <main+0x65>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <atoi@plt>
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
mov    %eax,%esi
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x28(%rbp),%rdi
call   1050 <kill@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%esi
lea    0xe48(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
cmp    $0x1,%edi
jg     1171 <main+0x31>
lea    0xeaf(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xb(%rsp),%rbx
xor    %edi,%edi
mov    %rbx,%rsi
mov    $0x5,%edx
call   1040 <read@plt>
mov    %rbx,%rdi
jmp    1175 <main+0x35>
mov    0x8(%rsi),%rdi
call   1060 <atoi@plt>
mov    %rax,%rbx
lea    0xe8a(%rip),%rdi
mov    %ebx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <kill@plt>
mov    %eax,%ebx
lea    0xe79(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    %ebx,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [14 x i8] c"Enter a pid: \00"
@.str.1 = [9 x i8] c"pid: %d\0A\00"
@.str.2 = [12 x i8] c"return: %d\0A\00"
define i32 @main(i32 %0, i8** %1, i8** %2) {
%4 = alloca i32
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8**
%8 = alloca [5 x i8]
%9 = alloca i64
%10 = alloca i32
store i32 0, i32* %4
store i32 %0, i32* %5
store i8** %1, i8*** %6
store i8** %2, i8*** %7
%11 = load i32, i32* %5
%12 = icmp slt i32 %11, 2
br i1 %12, label %13, label %19
13: ; preds = %3
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%15 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 0
%16 = call i32 @read(i32 0, i8* %15, i32 5)
%17 = getelementptr inbounds [5 x i8], [5 x i8]* %8, i64 0, i64 0
%18 = call i64 @atoi(i8* %17)
store i64 %18, i64* %9
br label %24
19: ; preds = %3
%20 = load i8**, i8*** %6
%21 = getelementptr inbounds i8*, i8** %20, i64 1
%22 = load i8*, i8** %21
%23 = call i64 @atoi(i8* %22)
store i64 %23, i64* %9
br label %24
24: ; preds = %19, %13
%25 = load i64, i64* %9
%26 = trunc i64 %25 to i32
%27 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %26)
%28 = load i64, i64* %9
%29 = call i32 @kill(i64 %28)
store i32 %29, i32* %10
%30 = load i32, i32* %10
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %30)
%32 = load i32, i32* %10
ret i32 %32
}

LLVM IR (-O2):
@.str = [14 x i8] c"Enter a pid: \00"
@.str.1 = [9 x i8] c"pid: %d\0A\00"
@.str.2 = [12 x i8] c"return: %d\0A\00"
define i32 @main(i32 %0, i8** nocapture %1, i8** nocapture readnone %2) {
%4 = alloca [5 x i8]
%5 = getelementptr inbounds [5 x i8], [5 x i8]* %4, i64 0, i64 0
%6 = icmp slt i32 %0, 2
br i1 %6, label %7, label %11
7: ; preds = %3
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([14 x i8], [14 x i8]* @.str, i64 0, i64 0))
%9 = call i32 @read(i32 0, i8* %5, i32 5)
%10 = call i64 @atoi(i8* %5)
br label %15
11: ; preds = %3
%12 = getelementptr inbounds i8*, i8** %1, i64 1
%13 = load i8*, i8** %12
%14 = tail call i64 @atoi(i8* %13)
br label %15
15: ; preds = %11, %7
%16 = phi i64 [ %10, %7 ], [ %14, %11 ]
%17 = trunc i64 %16 to i32
%18 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = tail call i32 @kill(i64 %16)
%20 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.2, i64 0, i64 0), i32 %19)
ret i32 %19
}