#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 */
int /*<<< orphan*/ SIGTERM;
scalar_t__ calloc(int, int);
int execvp(char *, char **);
scalar_t__ fork();
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int getopt(int, char **, char *);
scalar_t__ getppid();
int /*<<< orphan*/ kill(scalar_t__, int /*<<< orphan*/);
int /*<<< orphan*/ optarg;
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sleep(int);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ strdup(int /*<<< orphan*/);
int /*<<< orphan*/ strncpy(char *, char *, int);
scalar_t__ strtol(int /*<<< orphan*/, int /*<<< orphan*/ *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  int c;
  int timeout_val = -1;
  int option_count = 0;
  int verbose_flag = 0;
  pid_t cpid, ppid;
  int argc2;
  char **argv2;
  char *tmp;
  int i;
  int retval;
  if (argc < 2) {
    fprintf(stderr, "Usage:\n");
    fprintf(stderr, " timeout -t seconds [-v verbose] command line\n");
    return (0);
  }
  while ((c = getopt(argc, argv, "t:v")) != -1) {
    switch (c) {
    case 't':
      timeout_val = (int)strtol(strdup(optarg), NULL, 0);
      option_count += 2;
      break;
    case 'v':
      verbose_flag = 1;
      option_count++;
      break;
    }
  }
  if (timeout_val < 1) {
    fprintf(stderr, "timeout must be at least 1 second\n");
    return (-1);
  }
  argc2 = argc - option_count - 1;
  if ((argv2 = (char **)calloc(argc2, sizeof(char *))) == NULL) {
    fprintf(stderr, "error with calloc.\n");
    return (-1);
  }
  for (i = 0; i < argc2; i++) {
    if ((tmp = (char *)calloc(100, sizeof(char))) == NULL) {
      fprintf(stderr, "error with calloc.\n");
      return (-1);
    }
    argv2[i] = tmp;
    strncpy(argv2[i], argv[i + option_count + 1], 100);
  }
  if (verbose_flag) {
    printf("Running: %s\n", argv2[0]);
    printf("Will kill in %d seconds.\n", timeout_val);
  }
  cpid = fork();
  if (cpid > 0) {
    retval = execvp(argv2[0], argv2);
    if (retval != 0)
      fprintf(stderr, "exec error:%d (%m)\n", retval);
  } else {
    ppid = getppid();
    sleep(timeout_val);
    if (verbose_flag)
      printf("Killing %s [pid %d]\n", argv2[0], ppid);
    kill(ppid, SIGTERM);
    return (0);
  }
  return (0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x60,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0xffffffff,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
movl   $0x0,-0x20(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    122f <main+0x6f>
mov    0x2dd4(%rip),%rax
mov    (%rax),%edi
lea    0xdfb(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    0x2dbd(%rip),%rax
mov    (%rax),%edi
lea    0xdec(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0x0,-0x4(%rbp)
jmp    14a8 <main+0x2e8>
jmp    1234 <main+0x74>
mov    -0x8(%rbp),%edi
mov    -0x10(%rbp),%rsi
lea    0xdf5(%rip),%rdx
call   1090 <getopt@plt>
mov    %eax,-0x14(%rbp)
cmp    $0xffffffff,%eax
je     12b9 <main+0xf9>
mov    -0x14(%rbp),%eax
mov    %eax,-0x54(%rbp)
sub    $0x74,%eax
je     1278 <main+0xb8>
jmp    1267 <main+0xa7>
mov    -0x54(%rbp),%eax
sub    $0x76,%eax
je     12a4 <main+0xe4>
jmp    12b4 <main+0xf4>
mov    0x2d79(%rip),%rax
mov    (%rax),%edi
call   10c0 <strdup@plt>
mov    %eax,%edi
xor    %eax,%eax
mov    %eax,%esi
xor    %edx,%edx
call   1070 <strtol@plt>
mov    %eax,-0x18(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0x1c(%rbp)
jmp    12b4 <main+0xf4>
movl   $0x1,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    1234 <main+0x74>
cmpl   $0x1,-0x18(%rbp)
jge    12e6 <main+0x126>
mov    0x2d06(%rip),%rax
mov    (%rax),%edi
lea    0xd68(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14a8 <main+0x2e8>
mov    -0x8(%rbp),%eax
sub    -0x1c(%rbp),%eax
sub    $0x1,%eax
mov    %eax,-0x34(%rbp)
mov    -0x34(%rbp),%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
mov    %rax,-0x40(%rbp)
cmp    $0x0,%rax
jne    1330 <main+0x170>
mov    0x2cbc(%rip),%rax
mov    (%rax),%edi
lea    0xd41(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14a8 <main+0x2e8>
movl   $0x0,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
cmp    -0x34(%rbp),%eax
jge    13cb <main+0x20b>
mov    $0x64,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
mov    %rax,-0x48(%rbp)
cmp    $0x0,%rax
jne    1383 <main+0x1c3>
mov    0x2c69(%rip),%rax
mov    (%rax),%edi
lea    0xcee(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    14a8 <main+0x2e8>
mov    -0x48(%rbp),%rdx
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    %rdx,(%rax,%rcx,8)
mov    -0x40(%rbp),%rax
movslq -0x4c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
mov    -0x10(%rbp),%rax
mov    -0x4c(%rbp),%ecx
add    -0x1c(%rbp),%ecx
add    $0x1,%ecx
movslq %ecx,%rcx
mov    (%rax,%rcx,8),%rsi
mov    $0x64,%edx
call   1030 <strncpy@plt>
mov    -0x4c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x4c(%rbp)
jmp    1337 <main+0x177>
cmpl   $0x0,-0x20(%rbp)
je     13fb <main+0x23b>
mov    -0x40(%rbp),%rax
mov    (%rax),%rsi
lea    0xc8f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xc8b(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   10e0 <fork@plt>
mov    %rax,-0x28(%rbp)
cmpq   $0x0,-0x28(%rbp)
jle    144d <main+0x28d>
mov    -0x40(%rbp),%rax
mov    (%rax),%rdi
mov    -0x40(%rbp),%rsi
call   10a0 <execvp@plt>
mov    %eax,-0x50(%rbp)
cmpl   $0x0,-0x50(%rbp)
je     1448 <main+0x288>
mov    0x2b9b(%rip),%rax
mov    (%rax),%edi
mov    -0x50(%rbp),%edx
lea    0xc58(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
jmp    14a1 <main+0x2e1>
mov    $0x0,%al
call   10b0 <getppid@plt>
mov    %rax,-0x30(%rbp)
mov    -0x18(%rbp),%edi
call   10d0 <sleep@plt>
cmpl   $0x0,-0x20(%rbp)
je     1483 <main+0x2c3>
mov    -0x40(%rbp),%rax
mov    (%rax),%rsi
mov    -0x30(%rbp),%rdx
lea    0xc31(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x30(%rbp),%rdi
mov    0x2b52(%rip),%rax
mov    (%rax),%esi
call   1080 <kill@plt>
movl   $0x0,-0x4(%rbp)
jmp    14a8 <main+0x2e8>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x60,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
cmp    $0x2,%edi
jge    1203 <main+0x43>
mov    0x2df6(%rip),%rbp
mov    0x0(%rbp),%edi
lea    0xe1c(%rip),%rsi
xor    %ebx,%ebx
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    0x0(%rbp),%edi
lea    0xe11(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    13b3 <main+0x1f3>
mov    %rsi,%r13
mov    %edi,%ebx
lea    -0x1(%rbx),%r14d
mov    $0xffffffff,%eax
mov    %rax,0x8(%rsp)
xor    %r12d,%r12d
mov    $0x1,%al
mov    %eax,0x4(%rsp)
lea    0xe11(%rip),%r15
mov    %r14d,0x14(%rsp)
lea    0x1(%r12),%ebp
sub    %r12d,%r14d
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %ebx,%edi
mov    %r13,%rsi
mov    %r15,%rdx
call   1090 <getopt@plt>
cmp    $0xffffffff,%eax
je     12a3 <main+0xe3>
cmp    $0x76,%eax
je     1290 <main+0xd0>
cmp    $0x74,%eax
jne    1240 <main+0x80>
mov    0x2d95(%rip),%rax
mov    (%rax),%edi
call   10c0 <strdup@plt>
mov    %eax,%edi
xor    %esi,%esi
xor    %edx,%edx
call   1070 <strtol@plt>
mov    %rax,0x8(%rsp)
add    $0x2,%r12d
add    $0x2,%ebp
add    $0xfffffffe,%r14d
jmp    1240 <main+0x80>
nopw   0x0(%rax,%rax,1)
add    $0x1,%r12d
movl   $0x0,0x4(%rsp)
mov    0x14(%rsp),%r14d
jmp    122b <main+0x6b>
cmpl   $0x0,0x8(%rsp)
jle    1385 <main+0x1c5>
not    %r12d
add    %ebx,%r12d
mov    %r12d,%edi
mov    $0x8,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     1397 <main+0x1d7>
mov    %rax,%r15
test   %r12d,%r12d
jle    131d <main+0x15d>
mov    %r14d,%r14d
shl    $0x3,%r14
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    $0x64,%edi
mov    $0x1,%esi
call   1050 <calloc@plt>
test   %rax,%rax
je     1397 <main+0x1d7>
mov    %rax,(%r15,%rbx,1)
movslq %ebp,%rbp
mov    0x0(%r13,%rbp,8),%rsi
mov    %rax,%rdi
mov    $0x64,%edx
call   1030 <strncpy@plt>
add    $0x8,%rbx
add    $0x1,%ebp
cmp    %rbx,%r14
jne    12e0 <main+0x120>
mov    0x4(%rsp),%ebp
test   $0x1,%bpl
jne    134b <main+0x18b>
mov    (%r15),%rsi
lea    0xd41(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xd40(%rip),%rdi
mov    0x8(%rsp),%rsi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %ebx,%ebx
xor    %eax,%eax
call   10e0 <fork@plt>
test   %rax,%rax
jle    13c4 <main+0x204>
mov    (%r15),%rdi
mov    %r15,%rsi
call   10a0 <execvp@plt>
test   %eax,%eax
je     13b3 <main+0x1f3>
mov    0x2c61(%rip),%rcx
mov    (%rcx),%edi
lea    0xd21(%rip),%rsi
xor    %ebx,%ebx
mov    %eax,%edx
xor    %eax,%eax
call   1060 <fprintf@plt>
jmp    13b3 <main+0x1f3>
mov    0x2c44(%rip),%rax
mov    (%rax),%edi
lea    0xca6(%rip),%rsi
jmp    13a7 <main+0x1e7>
mov    0x2c32(%rip),%rax
mov    (%rax),%edi
lea    0xcb7(%rip),%rsi
xor    %eax,%eax
call   1060 <fprintf@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %ebx,%ebx
xor    %eax,%eax
call   10b0 <getppid@plt>
mov    %rax,%r12
mov    0x8(%rsp),%rdi
call   10d0 <sleep@plt>
test   $0x1,%bpl
jne    13f4 <main+0x234>
mov    (%r15),%rsi
lea    0xcc3(%rip),%rdi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2be5(%rip),%rax
mov    (%rax),%esi
mov    %r12,%rdi
call   1080 <kill@plt>
jmp    13b3 <main+0x1f3>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [8 x i8] c"Usage:\0A\00"
@.str.1 = [47 x i8] c" timeout -t seconds [-v verbose] command line\0A\00"
@.str.2 = [4 x i8] c"t:v\00"
@optarg = global i32 0
@.str.3 = [35 x i8] c"timeout must be at least 1 second\0A\00"
@.str.4 = [20 x i8] c"error with calloc.\0A\00"
@.str.5 = [13 x i8] c"Running: %s\0A\00"
@.str.6 = [26 x i8] c"Will kill in %d seconds.\0A\00"
@.str.7 = [20 x i8] c"exec error:%d (%m)\0A\00"
@.str.8 = [21 x i8] c"Killing %s [pid %d]\0A\00"
@SIGTERM = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i64
%11 = alloca i64
%12 = alloca i32
%13 = alloca i8**
%14 = alloca i8*
%15 = alloca i32
%16 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32 -1, i32* %7
store i32 0, i32* %8
store i32 0, i32* %9
%17 = load i32, i32* %4
%18 = icmp slt i32 %17, 2
br i1 %18, label %19, label %24
19: ; preds = %2
%20 = load i32, i32* @stderr
%21 = call i32 (i32, i8*, ...) @fprintf(i32 %20, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%22 = load i32, i32* @stderr
%23 = call i32 (i32, i8*, ...) @fprintf(i32 %22, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
store i32 0, i32* %3
br label %140
24: ; preds = %2
br label %25
25: ; preds = %42, %24
%26 = load i32, i32* %4
%27 = load i8**, i8*** %5
%28 = call i32 @getopt(i32 %26, i8** %27, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
store i32 %28, i32* %6
%29 = icmp ne i32 %28, -1
br i1 %29, label %30, label %43
30: ; preds = %25
%31 = load i32, i32* %6
switch i32 %31, label %42 [
i32 116, label %32
i32 118, label %39
]
32: ; preds = %30
%33 = load i32, i32* @optarg
%34 = call i32 @strdup(i32 %33)
%35 = call i64 @strtol(i32 %34, i32* null, i32 0)
%36 = trunc i64 %35 to i32
store i32 %36, i32* %7
%37 = load i32, i32* %8
%38 = add nsw i32 %37, 2
store i32 %38, i32* %8
br label %42
39: ; preds = %30
store i32 1, i32* %9
%40 = load i32, i32* %8
%41 = add nsw i32 %40, 1
store i32 %41, i32* %8
br label %42
42: ; preds = %30, %39, %32
br label %25
43: ; preds = %25
%44 = load i32, i32* %7
%45 = icmp slt i32 %44, 1
br i1 %45, label %46, label %49
46: ; preds = %43
%47 = load i32, i32* @stderr
%48 = call i32 (i32, i8*, ...) @fprintf(i32 %47, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
store i32 -1, i32* %3
br label %140
49: ; preds = %43
%50 = load i32, i32* %4
%51 = load i32, i32* %8
%52 = sub nsw i32 %50, %51
%53 = sub nsw i32 %52, 1
store i32 %53, i32* %12
%54 = load i32, i32* %12
%55 = call i64 @calloc(i32 %54, i32 8)
%56 = inttoptr i64 %55 to i8**
store i8** %56, i8*** %13
%57 = icmp eq i8** %56, null
br i1 %57, label %58, label %61
58: ; preds = %49
%59 = load i32, i32* @stderr
%60 = call i32 (i32, i8*, ...) @fprintf(i32 %59, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %140
61: ; preds = %49
store i32 0, i32* %15
br label %62
62: ; preds = %93, %61
%63 = load i32, i32* %15
%64 = load i32, i32* %12
%65 = icmp slt i32 %63, %64
br i1 %65, label %66, label %96
66: ; preds = %62
%67 = call i64 @calloc(i32 100, i32 1)
%68 = inttoptr i64 %67 to i8*
store i8* %68, i8** %14
%69 = icmp eq i8* %68, null
br i1 %69, label %70, label %73
70: ; preds = %66
%71 = load i32, i32* @stderr
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %71, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
store i32 -1, i32* %3
br label %140
73: ; preds = %66
%74 = load i8*, i8** %14
%75 = load i8**, i8*** %13
%76 = load i32, i32* %15
%77 = sext i32 %76 to i64
%78 = getelementptr inbounds i8*, i8** %75, i64 %77
store i8* %74, i8** %78
%79 = load i8**, i8*** %13
%80 = load i32, i32* %15
%81 = sext i32 %80 to i64
%82 = getelementptr inbounds i8*, i8** %79, i64 %81
%83 = load i8*, i8** %82
%84 = load i8**, i8*** %5
%85 = load i32, i32* %15
%86 = load i32, i32* %8
%87 = add nsw i32 %85, %86
%88 = add nsw i32 %87, 1
%89 = sext i32 %88 to i64
%90 = getelementptr inbounds i8*, i8** %84, i64 %89
%91 = load i8*, i8** %90
%92 = call i32 @strncpy(i8* %83, i8* %91, i32 100)
br label %93
93: ; preds = %73
%94 = load i32, i32* %15
%95 = add nsw i32 %94, 1
store i32 %95, i32* %15
br label %62
96: ; preds = %62
%97 = load i32, i32* %9
%98 = icmp ne i32 %97, 0
br i1 %98, label %99, label %106
99: ; preds = %96
%100 = load i8**, i8*** %13
%101 = getelementptr inbounds i8*, i8** %100, i64 0
%102 = load i8*, i8** %101
%103 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %102)
%104 = load i32, i32* %7
%105 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %104)
br label %106
106: ; preds = %99, %96
%107 = call i64 (...) @fork()
store i64 %107, i64* %10
%108 = load i64, i64* %10
%109 = icmp sgt i64 %108, 0
br i1 %109, label %110, label %123
110: ; preds = %106
%111 = load i8**, i8*** %13
%112 = getelementptr inbounds i8*, i8** %111, i64 0
%113 = load i8*, i8** %112
%114 = load i8**, i8*** %13
%115 = call i32 @execvp(i8* %113, i8** %114)
store i32 %115, i32* %16
%116 = load i32, i32* %16
%117 = icmp ne i32 %116, 0
br i1 %117, label %118, label %122
118: ; preds = %110
%119 = load i32, i32* @stderr
%120 = load i32, i32* %16
%121 = call i32 (i32, i8*, ...) @fprintf(i32 %119, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %120)
br label %122
122: ; preds = %118, %110
br label %139
123: ; preds = %106
%124 = call i64 (...) @getppid()
store i64 %124, i64* %11
%125 = load i32, i32* %7
%126 = call i32 @sleep(i32 %125)
%127 = load i32, i32* %9
%128 = icmp ne i32 %127, 0
br i1 %128, label %129, label %135
129: ; preds = %123
%130 = load i8**, i8*** %13
%131 = getelementptr inbounds i8*, i8** %130, i64 0
%132 = load i8*, i8** %131
%133 = load i64, i64* %11
%134 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %132, i64 %133)
br label %135
135: ; preds = %129, %123
%136 = load i64, i64* %11
%137 = load i32, i32* @SIGTERM
%138 = call i32 @kill(i64 %136, i32 %137)
store i32 0, i32* %3
br label %140
139: ; preds = %122
store i32 0, i32* %3
br label %140
140: ; preds = %139, %135, %70, %58, %46, %19
%141 = load i32, i32* %3
ret i32 %141
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [8 x i8] c"Usage:\0A\00"
@.str.1 = [47 x i8] c" timeout -t seconds [-v verbose] command line\0A\00"
@.str.2 = [4 x i8] c"t:v\00"
@optarg = global i32 0
@.str.3 = [35 x i8] c"timeout must be at least 1 second\0A\00"
@.str.4 = [20 x i8] c"error with calloc.\0A\00"
@.str.5 = [13 x i8] c"Running: %s\0A\00"
@.str.6 = [26 x i8] c"Will kill in %d seconds.\0A\00"
@.str.7 = [20 x i8] c"exec error:%d (%m)\0A\00"
@.str.8 = [21 x i8] c"Killing %s [pid %d]\0A\00"
@SIGTERM = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %22
4: ; preds = %2
%5 = load i32, i32* @stderr
%6 = tail call i32 (i32, i8*, ...) @fprintf(i32 %5, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%7 = load i32, i32* @stderr
%8 = tail call i32 (i32, i8*, ...) @fprintf(i32 %7, i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.1, i64 0, i64 0))
br label %87
9: ; preds = %17, %9
%10 = tail call i32 @getopt(i32 %0, i8** %1, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0))
switch i32 %10, label %9 [
i32 -1, label %26
i32 116, label %11
i32 118, label %20
]
11: ; preds = %9
%12 = load i32, i32* @optarg
%13 = tail call i32 @strdup(i32 %12)
%14 = tail call i64 @strtol(i32 %13, i32* null, i32 0)
%15 = trunc i64 %14 to i32
%16 = add nsw i32 %18, 2
br label %17
17: ; preds = %22, %11
%18 = phi i32 [ %24, %22 ], [ %16, %11 ]
%19 = phi i32 [ %25, %22 ], [ %15, %11 ]
br label %9
20: ; preds = %9
%21 = add nsw i32 %18, 1
br label %22
22: ; preds = %2, %20
%23 = phi i1 [ false, %20 ], [ true, %2 ]
%24 = phi i32 [ %21, %20 ], [ 0, %2 ]
%25 = phi i32 [ %19, %20 ], [ -1, %2 ]
br label %17
26: ; preds = %9
%27 = icmp slt i32 %19, 1
br i1 %27, label %28, label %31
28: ; preds = %26
%29 = load i32, i32* @stderr
%30 = tail call i32 (i32, i8*, ...) @fprintf(i32 %29, i8* getelementptr inbounds ([35 x i8], [35 x i8]* @.str.3, i64 0, i64 0))
br label %87
31: ; preds = %26
%32 = xor i32 %18, -1
%33 = add i32 %32, %0
%34 = tail call i64 @calloc(i32 %33, i32 8)
%35 = inttoptr i64 %34 to i8**
%36 = icmp eq i64 %34, 0
br i1 %36, label %42, label %37
37: ; preds = %31
%38 = icmp sgt i32 %33, 0
br i1 %38, label %39, label %63
39: ; preds = %37
%40 = add i32 %18, 1
%41 = zext i32 %33 to i64
br label %45
42: ; preds = %31
%43 = load i32, i32* @stderr
%44 = tail call i32 (i32, i8*, ...) @fprintf(i32 %43, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %87
45: ; preds = %39, %53
%46 = phi i64 [ 0, %39 ], [ %61, %53 ]
%47 = tail call i64 @calloc(i32 100, i32 1)
%48 = inttoptr i64 %47 to i8*
%49 = icmp eq i64 %47, 0
br i1 %49, label %50, label %53
50: ; preds = %45
%51 = load i32, i32* @stderr
%52 = tail call i32 (i32, i8*, ...) @fprintf(i32 %51, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.4, i64 0, i64 0))
br label %87
53: ; preds = %45
%54 = getelementptr inbounds i8*, i8** %35, i64 %46
store i8* %48, i8** %54
%55 = trunc i64 %46 to i32
%56 = add i32 %40, %55
%57 = sext i32 %56 to i64
%58 = getelementptr inbounds i8*, i8** %1, i64 %57
%59 = load i8*, i8** %58
%60 = tail call i32 @strncpy(i8* %48, i8* %59, i32 100)
%61 = add nuw nsw i64 %46, 1
%62 = icmp eq i64 %61, %41
br i1 %62, label %63, label %45
63: ; preds = %53, %37
br i1 %23, label %68, label %64
64: ; preds = %63
%65 = load i8*, i8** %35
%66 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %65)
%67 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.6, i64 0, i64 0), i32 %19)
br label %68
68: ; preds = %64, %63
%69 = tail call i64 (...) @fork()
%70 = icmp sgt i64 %69, 0
br i1 %70, label %71, label %78
71: ; preds = %68
%72 = load i8*, i8** %35
%73 = tail call i32 @execvp(i8* %72, i8** %35)
%74 = icmp eq i32 %73, 0
br i1 %74, label %87, label %75
75: ; preds = %71
%76 = load i32, i32* @stderr
%77 = tail call i32 (i32, i8*, ...) @fprintf(i32 %76, i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.7, i64 0, i64 0), i32 %73)
br label %87
78: ; preds = %68
%79 = tail call i64 (...) @getppid()
%80 = tail call i32 @sleep(i32 %19)
br i1 %23, label %84, label %81
81: ; preds = %78
%82 = load i8*, i8** %35
%83 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.8, i64 0, i64 0), i8* %82, i64 %79)
br label %84
84: ; preds = %81, %78
%85 = load i32, i32* @SIGTERM
%86 = tail call i32 @kill(i64 %79, i32 %85)
br label %87
87: ; preds = %75, %71, %84, %50, %42, %28, %4
%88 = phi i32 [ 0, %4 ], [ -1, %28 ], [ -1, %42 ], [ -1, %50 ], [ 0, %84 ], [ 0, %71 ], [ 0, %75 ]
ret i32 %88
}