#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 /*<<< orphan*/ SIGUSR1;
int atoi(char *);
int /*<<< orphan*/ drop_privs();
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ init_privs();
int /*<<< orphan*/ isdigit(char);
int /*<<< orphan*/ kill(int, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, ...);
int /*<<< orphan*/ set_privs();
int strlen(char *);
int main(int argc, char *argv[]) {
  int pid, index, usable;
  char *pgname;
  pgname = argv[0];
  if (argc < 2) {
    printf("%s: nothing to do\n", pgname);
    exit(0);
  }
  init_privs();
  set_privs();
  while (argc > 1) {
    usable = 1;
    for (index = 0; index < strlen(argv[1]); index++) {
      if (!isdigit(argv[1][index])) {
        usable = 0;
        break;
      }
    }
    if (usable) {
      pid = atoi(argv[1]);
      kill(pid, SIGUSR1);
    } else
      printf("%s: invalid argument %s\n", pgname, argv[1]);
    argc--;
    argv++;
  }
  drop_privs();
  exit(0);
}


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    -0x10(%rbp),%rax
mov    (%rax),%rax
mov    %rax,-0x28(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    11d4 <main+0x44>
mov    -0x28(%rbp),%rsi
lea    0xe3a(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    $0x0,%al
call   1090 <init_privs@plt>
mov    $0x0,%al
call   1070 <set_privs@plt>
cmpl   $0x1,-0x8(%rbp)
jle    12bb <main+0x12b>
movl   $0x1,-0x1c(%rbp)
movl   $0x0,-0x18(%rbp)
mov    -0x18(%rbp),%eax
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1050 <strlen@plt>
mov    %eax,%ecx
mov    -0x2c(%rbp),%eax
cmp    %ecx,%eax
jge    1257 <main+0xc7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
movslq -0x18(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%eax
jne    1244 <main+0xb4>
movl   $0x0,-0x1c(%rbp)
jmp    1257 <main+0xc7>
jmp    1249 <main+0xb9>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    11fa <main+0x6a>
cmpl   $0x0,-0x1c(%rbp)
je     1287 <main+0xf7>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   10a0 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%edi
mov    0x2d6d(%rip),%rax
mov    (%rax),%esi
call   1080 <kill@plt>
jmp    12a1 <main+0x111>
mov    -0x28(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xd79(%rip),%rdi
mov    $0x0,%al
call   1060 <printf@plt>
mov    -0x8(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x8(%rbp)
mov    -0x10(%rbp),%rax
add    $0x8,%rax
mov    %rax,-0x10(%rbp)
jmp    11e2 <main+0x52>
mov    $0x0,%al
call   1040 <drop_privs@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    (%rsi),%r14
cmp    $0x1,%edi
jg     11bb <main+0x2b>
lea    0xe56(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   10b0 <exit@plt>
mov    %rsi,%rbx
mov    %edi,%r15d
xor    %eax,%eax
call   1090 <init_privs@plt>
xor    %eax,%eax
call   1070 <set_privs@plt>
lea    0xe3d(%rip),%r12
mov    0x2e0b(%rip),%r13
jmp    1200 <main+0x70>
nop
mov    (%rbx),%rdi
call   10a0 <atoi@plt>
mov    0x0(%r13),%esi
mov    %eax,%edi
call   1080 <kill@plt>
lea    -0x1(%r15),%eax
cmp    $0x2,%r15d
mov    %eax,%r15d
jle    125f <main+0xcf>
mov    0x8(%rbx),%rdi
add    $0x8,%rbx
call   1050 <strlen@plt>
test   %eax,%eax
jle    11e0 <main+0x50>
xor    %ebp,%ebp
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    (%rbx),%rax
movsbl (%rax,%rbp,1),%edi
call   1030 <isdigit@plt>
mov    (%rbx),%rdx
test   %eax,%eax
je     1250 <main+0xc0>
add    $0x1,%rbp
mov    %rdx,%rdi
call   1050 <strlen@plt>
cltq
cmp    %rax,%rbp
jl     1220 <main+0x90>
jmp    11e0 <main+0x50>
nopl   0x0(%rax,%rax,1)
mov    %r12,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
jmp    11f3 <main+0x63>
xor    %eax,%eax
call   1040 <drop_privs@plt>
xor    %edi,%edi
call   10b0 <exit@plt>

LLVM IR (-O0):
@.str = [19 x i8] c"%s: nothing to do\0A\00"
@SIGUSR1 = global i32 0
@.str.1 = [25 x i8] c"%s: invalid argument %s\0A\00"
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 i8*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 0
%12 = load i8*, i8** %11
store i8* %12, i8** %9
%13 = load i32, i32* %4
%14 = icmp slt i32 %13, 2
br i1 %14, label %15, label %19
15: ; preds = %2
%16 = load i8*, i8** %9
%17 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %16)
%18 = call i32 @exit(i32 0)
unreachable
19: ; preds = %2
%20 = call i32 (...) @init_privs()
%21 = call i32 (...) @set_privs()
br label %22
22: ; preds = %65, %19
%23 = load i32, i32* %4
%24 = icmp sgt i32 %23, 1
br i1 %24, label %25, label %70
25: ; preds = %22
store i32 1, i32* %8
store i32 0, i32* %7
br label %26
26: ; preds = %45, %25
%27 = load i32, i32* %7
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = call i32 @strlen(i8* %30)
%32 = icmp slt i32 %27, %31
br i1 %32, label %33, label %48
33: ; preds = %26
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = load i32, i32* %7
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds i8, i8* %36, i64 %38
%40 = load i8, i8* %39
%41 = call i32 @isdigit(i8 signext %40)
%42 = icmp ne i32 %41, 0
br i1 %42, label %44, label %43
43: ; preds = %33
store i32 0, i32* %8
br label %48
44: ; preds = %33
br label %45
45: ; preds = %44
%46 = load i32, i32* %7
%47 = add nsw i32 %46, 1
store i32 %47, i32* %7
br label %26
48: ; preds = %43, %26
%49 = load i32, i32* %8
%50 = icmp ne i32 %49, 0
br i1 %50, label %51, label %59
51: ; preds = %48
%52 = load i8**, i8*** %5
%53 = getelementptr inbounds i8*, i8** %52, i64 1
%54 = load i8*, i8** %53
%55 = call i32 @atoi(i8* %54)
store i32 %55, i32* %6
%56 = load i32, i32* %6
%57 = load i32, i32* @SIGUSR1
%58 = call i32 @kill(i32 %56, i32 %57)
br label %65
59: ; preds = %48
%60 = load i8*, i8** %9
%61 = load i8**, i8*** %5
%62 = getelementptr inbounds i8*, i8** %61, i64 1
%63 = load i8*, i8** %62
%64 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %60, i8* %63)
br label %65
65: ; preds = %59, %51
%66 = load i32, i32* %4
%67 = add nsw i32 %66, -1
store i32 %67, i32* %4
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i32 1
store i8** %69, i8*** %5
br label %22
70: ; preds = %22
%71 = call i32 (...) @drop_privs()
%72 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@.str = [19 x i8] c"%s: nothing to do\0A\00"
@SIGUSR1 = global i32 0
@.str.1 = [25 x i8] c"%s: invalid argument %s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = load i8*, i8** %1
%4 = icmp slt i32 %0, 2
br i1 %4, label %5, label %8
5: ; preds = %2
%6 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str, i64 0, i64 0), i8* %3)
%7 = tail call i32 @exit(i32 0)
unreachable
8: ; preds = %2
%9 = tail call i32 (...) @init_privs()
%10 = tail call i32 (...) @set_privs()
br label %11
11: ; preds = %8, %38
%12 = phi i32 [ %0, %8 ], [ %39, %38 ]
%13 = phi i8** [ %1, %8 ], [ %14, %38 ]
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = tail call i32 @strlen(i8* %15)
%17 = icmp sgt i32 %16, 0
br i1 %17, label %22, label %31
18: ; preds = %22
%19 = tail call i32 @strlen(i8* %30)
%20 = sext i32 %19 to i64
%21 = icmp slt i64 %29, %20
br i1 %21, label %22, label %31
22: ; preds = %11, %18
%23 = phi i64 [ %29, %18 ], [ 0, %11 ]
%24 = load i8*, i8** %14
%25 = getelementptr inbounds i8, i8* %24, i64 %23
%26 = load i8, i8* %25
%27 = tail call i32 @isdigit(i8 signext %26)
%28 = icmp eq i32 %27, 0
%29 = add nuw nsw i64 %23, 1
%30 = load i8*, i8** %14
br i1 %28, label %36, label %18
31: ; preds = %18, %11
%32 = load i8*, i8** %14
%33 = tail call i32 @atoi(i8* %32)
%34 = load i32, i32* @SIGUSR1
%35 = tail call i32 @kill(i32 %33, i32 %34)
br label %38
36: ; preds = %22
%37 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.1, i64 0, i64 0), i8* %3, i8* %30)
br label %38
38: ; preds = %36, %31
%39 = add nsw i32 %12, -1
%40 = icmp sgt i32 %12, 2
br i1 %40, label %11, label %41
41: ; preds = %38
%42 = tail call i32 (...) @drop_privs()
%43 = tail call i32 @exit(i32 0)
unreachable
}