#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 atoi(char *);
int kill(int, int);
int /*<<< orphan*/ perror(char *);
void cmd_kill(int argc, char *argv[]) {
  int killsig = 9;
  if (argc > 1)
    killsig = atoi(argv[2]);
  if (kill(atoi(argv[1]), killsig) == -1)
    perror("kill");
}


x86 assembly (clang, -O0):
<cmd_kill>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x9,-0x14(%rbp)
cmpl   $0x1,-0x4(%rbp)
jle    1160 <cmd_kill+0x30>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <atoi@plt>
mov    %eax,%edi
mov    -0x14(%rbp),%esi
call   1030 <kill@plt>
cmp    $0xffffffff,%eax
jne    118c <cmd_kill+0x5c>
lea    0xe79(%rip),%rdi
call   1040 <perror@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<cmd_kill>:
push   %rbp
push   %rbx
push   %rax
mov    %rsi,%rbx
mov    $0x9,%ebp
cmp    $0x2,%edi
jl     114b <cmd_kill+0x1b>
mov    0x10(%rbx),%rdi
call   1050 <atoi@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
call   1050 <atoi@plt>
mov    %eax,%edi
mov    %ebp,%esi
call   1030 <kill@plt>
cmp    $0xffffffff,%eax
je     1169 <cmd_kill+0x39>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
lea    0xe90(%rip),%rdi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <perror@plt>

LLVM IR (-O0):
@.str = [5 x i8] c"kill\00"
define void @cmd_kill(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i32
store i32 %0, i32* %3
store i8** %1, i8*** %4
store i32 9, i32* %5
%6 = load i32, i32* %3
%7 = icmp sgt i32 %6, 1
br i1 %7, label %8, label %13
8: ; preds = %2
%9 = load i8**, i8*** %4
%10 = getelementptr inbounds i8*, i8** %9, i64 2
%11 = load i8*, i8** %10
%12 = call i32 @atoi(i8* %11)
store i32 %12, i32* %5
br label %13
13: ; preds = %8, %2
%14 = load i8**, i8*** %4
%15 = getelementptr inbounds i8*, i8** %14, i64 1
%16 = load i8*, i8** %15
%17 = call i32 @atoi(i8* %16)
%18 = load i32, i32* %5
%19 = call i32 @kill(i32 %17, i32 %18)
%20 = icmp eq i32 %19, -1
br i1 %20, label %21, label %23
21: ; preds = %13
%22 = call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %23
23: ; preds = %21, %13
ret void
}

LLVM IR (-O2):
@.str = [5 x i8] c"kill\00"
define void @cmd_kill(i32 %0, i8** nocapture %1) {
%3 = icmp sgt i32 %0, 1
br i1 %3, label %4, label %8
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i32 @atoi(i8* %6)
br label %8
8: ; preds = %4, %2
%9 = phi i32 [ %7, %4 ], [ 9, %2 ]
%10 = getelementptr inbounds i8*, i8** %1, i64 1
%11 = load i8*, i8** %10
%12 = tail call i32 @atoi(i8* %11)
%13 = tail call i32 @kill(i32 %12, i32 %9)
%14 = icmp eq i32 %13, -1
br i1 %14, label %15, label %17
15: ; preds = %8
%16 = tail call i32 @perror(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0))
br label %17
17: ; preds = %15, %8
ret void
}