#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*/ EXIT_SUCCESS;
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdout;
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage();
int getInput(int argc, char *argv[], int *method) {
  int number;
  if (argc < 3 || argc > 4) {
    fprintf(stderr, "Invalid usage.\n");
    usage();
  }
  if (strcmp("thread", argv[1]) == 0) {
    (*method) = 0;
  } else if (strcmp("process", argv[1]) == 0) {
    (*method) = 1;
  } else {
    fprintf(stderr, "Invalid flag: %s.\n", argv[1]);
    usage();
  }
  sscanf(argv[2], "%d", &number);
  if (number < 1 || number > 50) {
    fprintf(stderr, "Invalid number: %s.\n", argv[2]);
    usage();
  }
  if ((*method) == 1) {
    fprintf(stdout, "Processes method not yet implemented.\n");
    exit(EXIT_SUCCESS);
  }
  sscanf(argv[2], "%d", &number);
  if ((*method) == 1) {
    if (number > 200) {
      fprintf(stderr, "Invalid number: %s.\n", argv[2]);
      usage();
    }
  }
  if ((*method) == 0) {
    if (number > 50) {
      fprintf(stderr, "Invalid number: %s.\n", argv[2]);
      usage();
    }
  }
  return number;
}


x86 assembly (clang, -O0):
<getInput>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
cmpl   $0x3,-0x4(%rbp)
jl     1177 <getInput+0x27>
cmpl   $0x4,-0x4(%rbp)
jle    1195 <getInput+0x45>
mov    0x2e62(%rip),%rax
mov    (%rax),%edi
lea    0xe79(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1060 <usage@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe6c(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11c2 <getInput+0x72>
mov    -0x18(%rbp),%rax
movl   $0x0,(%rax)
jmp    121a <getInput+0xca>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rsi
lea    0xe46(%rip),%rdi
call   1030 <strcmp@plt>
cmp    $0x0,%rax
jne    11ef <getInput+0x9f>
mov    -0x18(%rbp),%rax
movl   $0x1,(%rax)
jmp    1215 <getInput+0xc5>
mov    0x2dea(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdx
lea    0xe18(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    121a <getInput+0xca>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe09(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <sscanf@plt>
cmpl   $0x1,-0x1c(%rbp)
jl     1246 <getInput+0xf6>
cmpl   $0x32,-0x1c(%rbp)
jle    126c <getInput+0x11c>
mov    0x2d93(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xdd7(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1060 <usage@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x1,(%rax)
jne    129e <getInput+0x14e>
mov    0x2d58(%rip),%rax
mov    (%rax),%edi
lea    0xdc1(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    0x2d39(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xd85(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x18(%rbp),%rax
cmpl   $0x1,(%rax)
jne    12fb <getInput+0x1ab>
cmpl   $0xc8,-0x1c(%rbp)
jle    12f6 <getInput+0x1a6>
mov    0x2d09(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xd4d(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    12fb <getInput+0x1ab>
mov    -0x18(%rbp),%rax
cmpl   $0x0,(%rax)
jne    133d <getInput+0x1ed>
cmpl   $0x32,-0x1c(%rbp)
jle    1338 <getInput+0x1e8>
mov    0x2cc7(%rip),%rax
mov    (%rax),%edi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdx
lea    0xd0b(%rip),%rsi
mov    $0x0,%al
call   1040 <fprintf@plt>
mov    $0x0,%al
call   1060 <usage@plt>
jmp    133d <getInput+0x1ed>
mov    -0x1c(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<getInput>:
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%rbx
add    $0xfffffffb,%edi
cmp    $0xfffffffd,%edi
ja     1180 <getInput+0x30>
mov    0x2e77(%rip),%rax
mov    (%rax),%edi
lea    0xe8e(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1060 <usage@plt>
mov    0x8(%rbx),%rsi
lea    0xe85(%rip),%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11ce <getInput+0x7e>
mov    0x8(%rbx),%rsi
lea    0xe77(%rip),%rdi
call   1030 <strcmp@plt>
test   %rax,%rax
je     11d7 <getInput+0x87>
mov    0x2e2f(%rip),%rax
mov    (%rax),%edi
mov    0x8(%rbx),%rdx
lea    0xe61(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1060 <usage@plt>
jmp    11de <getInput+0x8e>
movl   $0x0,(%r14)
jmp    11de <getInput+0x8e>
movl   $0x1,(%r14)
mov    0x10(%rbx),%rdi
lea    0xe49(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1050 <sscanf@plt>
mov    0x4(%rsp),%eax
add    $0xffffffcd,%eax
cmp    $0xffffffcd,%eax
ja     1221 <getInput+0xd1>
mov    0x2dda(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xe22(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1060 <usage@plt>
cmpl   $0x1,(%r14)
je     12b3 <getInput+0x163>
mov    0x10(%rbx),%rdi
lea    0xdfc(%rip),%rsi
lea    0x4(%rsp),%rdx
call   1050 <sscanf@plt>
mov    (%r14),%ecx
mov    0x4(%rsp),%eax
cmp    $0x1,%ecx
jne    127c <getInput+0x12c>
cmp    $0xc9,%eax
jl     127c <getInput+0x12c>
mov    0x2d86(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xdce(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1060 <usage@plt>
mov    (%r14),%ecx
mov    0x4(%rsp),%eax
test   %ecx,%ecx
jne    12ab <getInput+0x15b>
cmp    $0x33,%eax
jl     12ab <getInput+0x15b>
mov    0x2d54(%rip),%rax
mov    (%rax),%edi
mov    0x10(%rbx),%rdx
lea    0xd9c(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
xor    %eax,%eax
call   1060 <usage@plt>
mov    0x4(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    0x2d1e(%rip),%rax
mov    (%rax),%edi
lea    0xd87(%rip),%rsi
xor    %eax,%eax
call   1040 <fprintf@plt>
mov    0x2cff(%rip),%rax
mov    (%rax),%edi
call   1070 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [16 x i8] c"Invalid usage.\0A\00"
@.str.1 = [7 x i8] c"thread\00"
@.str.2 = [8 x i8] c"process\00"
@.str.3 = [19 x i8] c"Invalid flag: %s.\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [21 x i8] c"Invalid number: %s.\0A\00"
@stdout = global i32 0
@.str.6 = [39 x i8] c"Processes method not yet implemented.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @getInput(i32 %0, i8** %1, i32* %2) {
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32*
%7 = alloca i32
store i32 %0, i32* %4
store i8** %1, i8*** %5
store i32* %2, i32** %6
%8 = load i32, i32* %4
%9 = icmp slt i32 %8, 3
br i1 %9, label %13, label %10
10: ; preds = %3
%11 = load i32, i32* %4
%12 = icmp sgt i32 %11, 4
br i1 %12, label %13, label %17
13: ; preds = %10, %3
%14 = load i32, i32* @stderr
%15 = call i32 (i32, i8*, ...) @fprintf(i32 %14, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%16 = call i32 (...) @usage()
br label %17
17: ; preds = %13, %10
%18 = load i8**, i8*** %5
%19 = getelementptr inbounds i8*, i8** %18, i64 1
%20 = load i8*, i8** %19
%21 = call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %20)
%22 = icmp eq i64 %21, 0
br i1 %22, label %23, label %25
23: ; preds = %17
%24 = load i32*, i32** %6
store i32 0, i32* %24
br label %41
25: ; preds = %17
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %28)
%30 = icmp eq i64 %29, 0
br i1 %30, label %31, label %33
31: ; preds = %25
%32 = load i32*, i32** %6
store i32 1, i32* %32
br label %40
33: ; preds = %25
%34 = load i32, i32* @stderr
%35 = load i8**, i8*** %5
%36 = getelementptr inbounds i8*, i8** %35, i64 1
%37 = load i8*, i8** %36
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %34, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %37)
%39 = call i32 (...) @usage()
br label %40
40: ; preds = %33, %31
br label %41
41: ; preds = %40, %23
%42 = load i8**, i8*** %5
%43 = getelementptr inbounds i8*, i8** %42, i64 2
%44 = load i8*, i8** %43
%45 = call i32 @sscanf(i8* %44, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %7)
%46 = load i32, i32* %7
%47 = icmp slt i32 %46, 1
br i1 %47, label %51, label %48
48: ; preds = %41
%49 = load i32, i32* %7
%50 = icmp sgt i32 %49, 50
br i1 %50, label %51, label %58
51: ; preds = %48, %41
%52 = load i32, i32* @stderr
%53 = load i8**, i8*** %5
%54 = getelementptr inbounds i8*, i8** %53, i64 2
%55 = load i8*, i8** %54
%56 = call i32 (i32, i8*, ...) @fprintf(i32 %52, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %55)
%57 = call i32 (...) @usage()
br label %58
58: ; preds = %51, %48
%59 = load i32*, i32** %6
%60 = load i32, i32* %59
%61 = icmp eq i32 %60, 1
br i1 %61, label %62, label %67
62: ; preds = %58
%63 = load i32, i32* @stdout
%64 = call i32 (i32, i8*, ...) @fprintf(i32 %63, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
%65 = load i32, i32* @EXIT_SUCCESS
%66 = call i32 @exit(i32 %65)
unreachable
67: ; preds = %58
%68 = load i8**, i8*** %5
%69 = getelementptr inbounds i8*, i8** %68, i64 2
%70 = load i8*, i8** %69
%71 = call i32 @sscanf(i8* %70, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %7)
%72 = load i32*, i32** %6
%73 = load i32, i32* %72
%74 = icmp eq i32 %73, 1
br i1 %74, label %75, label %86
75: ; preds = %67
%76 = load i32, i32* %7
%77 = icmp sgt i32 %76, 200
br i1 %77, label %78, label %85
78: ; preds = %75
%79 = load i32, i32* @stderr
%80 = load i8**, i8*** %5
%81 = getelementptr inbounds i8*, i8** %80, i64 2
%82 = load i8*, i8** %81
%83 = call i32 (i32, i8*, ...) @fprintf(i32 %79, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %82)
%84 = call i32 (...) @usage()
br label %85
85: ; preds = %78, %75
br label %86
86: ; preds = %85, %67
%87 = load i32*, i32** %6
%88 = load i32, i32* %87
%89 = icmp eq i32 %88, 0
br i1 %89, label %90, label %101
90: ; preds = %86
%91 = load i32, i32* %7
%92 = icmp sgt i32 %91, 50
br i1 %92, label %93, label %100
93: ; preds = %90
%94 = load i32, i32* @stderr
%95 = load i8**, i8*** %5
%96 = getelementptr inbounds i8*, i8** %95, i64 2
%97 = load i8*, i8** %96
%98 = call i32 (i32, i8*, ...) @fprintf(i32 %94, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %97)
%99 = call i32 (...) @usage()
br label %100
100: ; preds = %93, %90
br label %101
101: ; preds = %100, %86
%102 = load i32, i32* %7
ret i32 %102
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [16 x i8] c"Invalid usage.\0A\00"
@.str.1 = [7 x i8] c"thread\00"
@.str.2 = [8 x i8] c"process\00"
@.str.3 = [19 x i8] c"Invalid flag: %s.\0A\00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [21 x i8] c"Invalid number: %s.\0A\00"
@stdout = global i32 0
@.str.6 = [39 x i8] c"Processes method not yet implemented.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @getInput(i32 %0, i8** nocapture %1, i32* nocapture %2) {
%4 = alloca i32
%5 = bitcast i32* %4 to i8*
%6 = add i32 %0, -5
%7 = icmp ult i32 %6, -2
br i1 %7, label %8, label %12
8: ; preds = %3
%9 = load i32, i32* @stderr
%10 = tail call i32 (i32, i8*, ...) @fprintf(i32 %9, i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%11 = tail call i32 (...) @usage()
br label %12
12: ; preds = %3, %8
%13 = getelementptr inbounds i8*, i8** %1, i64 1
%14 = load i8*, i8** %13
%15 = tail call i64 @strcmp(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0), i8* %14)
%16 = icmp eq i64 %15, 0
br i1 %16, label %17, label %18
17: ; preds = %12
store i32 0, i32* %2
br label %28
18: ; preds = %12
%19 = load i8*, i8** %13
%20 = tail call i64 @strcmp(i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.2, i64 0, i64 0), i8* %19)
%21 = icmp eq i64 %20, 0
br i1 %21, label %22, label %23
22: ; preds = %18
store i32 1, i32* %2
br label %28
23: ; preds = %18
%24 = load i32, i32* @stderr
%25 = load i8*, i8** %13
%26 = tail call i32 (i32, i8*, ...) @fprintf(i32 %24, i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.3, i64 0, i64 0), i8* %25)
%27 = tail call i32 (...) @usage()
br label %28
28: ; preds = %22, %23, %17
%29 = getelementptr inbounds i8*, i8** %1, i64 2
%30 = load i8*, i8** %29
%31 = call i32 @sscanf(i8* %30, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%32 = load i32, i32* %4
%33 = add i32 %32, -51
%34 = icmp ult i32 %33, -50
br i1 %34, label %35, label %40
35: ; preds = %28
%36 = load i32, i32* @stderr
%37 = load i8*, i8** %29
%38 = call i32 (i32, i8*, ...) @fprintf(i32 %36, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %37)
%39 = call i32 (...) @usage()
br label %40
40: ; preds = %28, %35
%41 = load i32, i32* %2
%42 = icmp eq i32 %41, 1
br i1 %42, label %43, label %48
43: ; preds = %40
%44 = load i32, i32* @stdout
%45 = call i32 (i32, i8*, ...) @fprintf(i32 %44, i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.6, i64 0, i64 0))
%46 = load i32, i32* @EXIT_SUCCESS
%47 = call i32 @exit(i32 %46)
unreachable
48: ; preds = %40
%49 = load i8*, i8** %29
%50 = call i32 @sscanf(i8* %49, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32* %4)
%51 = load i32, i32* %2
%52 = icmp eq i32 %51, 1
%53 = load i32, i32* %4
%54 = icmp sgt i32 %53, 200
%55 = select i1 %52, i1 %54, i1 false
br i1 %55, label %56, label %63
56: ; preds = %48
%57 = load i32, i32* @stderr
%58 = load i8*, i8** %29
%59 = call i32 (i32, i8*, ...) @fprintf(i32 %57, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %58)
%60 = call i32 (...) @usage()
%61 = load i32, i32* %2
%62 = load i32, i32* %4
br label %63
63: ; preds = %56, %48
%64 = phi i32 [ %62, %56 ], [ %53, %48 ]
%65 = phi i32 [ %61, %56 ], [ %51, %48 ]
%66 = icmp eq i32 %65, 0
%67 = icmp sgt i32 %64, 50
%68 = select i1 %66, i1 %67, i1 false
br i1 %68, label %69, label %75
69: ; preds = %63
%70 = load i32, i32* @stderr
%71 = load i8*, i8** %29
%72 = call i32 (i32, i8*, ...) @fprintf(i32 %70, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.5, i64 0, i64 0), i8* %71)
%73 = call i32 (...) @usage()
%74 = load i32, i32* %4
br label %75
75: ; preds = %69, %63
%76 = phi i32 [ %74, %69 ], [ %64, %63 ]
ret i32 %76
}