#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(int);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/, char *, int);
scalar_t__ isdigit(unsigned int);
int /*<<< orphan*/ stderr;
int strlen(char *);
void check_integer(char *tocheck, int which) {
  int i, n;
  char ok = 1;
  n = strlen(tocheck);
  ok = (tocheck[0] == '-') || isdigit((unsigned int)tocheck[0]);
  if (ok)
    for (i = 1; i < n; i++)
      if (!isdigit((unsigned int)tocheck[i]))
        ok = 0;
  if (!ok) {
    fprintf(stderr,
            "Wrong type of parameter for flag -%c. Has to be an "
            "integer\n",
            which);
    exit(2);
  }
}


x86 assembly (clang, -O0):
<check_integer>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movb   $0x1,-0x15(%rbp)
mov    -0x8(%rbp),%rdi
call   1040 <strlen@plt>
mov    %eax,-0x14(%rbp)
mov    -0x8(%rbp),%rax
movsbl (%rax),%ecx
mov    $0x1,%al
cmp    $0x2d,%ecx
mov    %al,-0x16(%rbp)
je     118a <check_integer+0x4a>
mov    -0x8(%rbp),%rax
movsbl (%rax),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
setne  %al
mov    %al,-0x16(%rbp)
mov    -0x16(%rbp),%al
and    $0x1,%al
movzbl %al,%eax
mov    %al,-0x15(%rbp)
cmpb   $0x0,-0x15(%rbp)
je     11e9 <check_integer+0xa9>
movl   $0x1,-0x10(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
jge    11e4 <check_integer+0xa4>
mov    -0x8(%rbp),%rax
movslq -0x10(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    11d1 <check_integer+0x91>
movb   $0x0,-0x15(%rbp)
jmp    11d6 <check_integer+0x96>
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    11a6 <check_integer+0x66>
jmp    11e9 <check_integer+0xa9>
cmpb   $0x0,-0x15(%rbp)
jne    1215 <check_integer+0xd5>
mov    0x2de6(%rip),%rax
mov    (%rax),%edi
mov    -0xc(%rbp),%edx
lea    0xdfa(%rip),%rsi
call   1050 <fprintf@plt>
mov    $0x2,%edi
call   1060 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_integer>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %esi,%r14d
mov    %rdi,%r15
call   1040 <strlen@plt>
mov    %eax,%ebp
movsbl (%r15),%edi
cmp    $0x2d,%edi
je     116b <check_integer+0x2b>
call   1030 <isdigit@plt>
test   %rax,%rax
je     11b0 <check_integer+0x70>
cmp    $0x2,%ebp
jl     11a1 <check_integer+0x61>
mov    %ebp,%r12d
mov    $0x1,%bl
mov    $0x1,%ebp
xor    %r13d,%r13d
nopl   (%rax)
movsbl (%r15,%rbp,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
movzbl %bl,%ebx
cmove  %r13d,%ebx
add    $0x1,%rbp
cmp    %rbp,%r12
jne    1180 <check_integer+0x40>
test   %bl,%bl
je     11b0 <check_integer+0x70>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2e29(%rip),%rax
mov    (%rax),%edi
lea    0xe40(%rip),%rsi
mov    %r14d,%edx
call   1050 <fprintf@plt>
mov    $0x2,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@stderr = global i32 0
@.str = [60 x i8] c"Wrong type of parameter for flag -%c. Has to be an integer\0A\00"
define void @check_integer(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i8
store i8* %0, i8** %3
store i32 %1, i32* %4
store i8 1, i8* %7
%8 = load i8*, i8** %3
%9 = call i32 @strlen(i8* %8)
store i32 %9, i32* %6
%10 = load i8*, i8** %3
%11 = getelementptr inbounds i8, i8* %10, i64 0
%12 = load i8, i8* %11
%13 = sext i8 %12 to i32
%14 = icmp eq i32 %13, 45
br i1 %14, label %22, label %15
15: ; preds = %2
%16 = load i8*, i8** %3
%17 = getelementptr inbounds i8, i8* %16, i64 0
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = call i64 @isdigit(i32 %19)
%21 = icmp ne i64 %20, 0
br label %22
22: ; preds = %15, %2
%23 = phi i1 [ true, %2 ], [ %21, %15 ]
%24 = zext i1 %23 to i32
%25 = trunc i32 %24 to i8
store i8 %25, i8* %7
%26 = load i8, i8* %7
%27 = icmp ne i8 %26, 0
br i1 %27, label %28, label %48
28: ; preds = %22
store i32 1, i32* %5
br label %29
29: ; preds = %44, %28
%30 = load i32, i32* %5
%31 = load i32, i32* %6
%32 = icmp slt i32 %30, %31
br i1 %32, label %33, label %47
33: ; preds = %29
%34 = load i8*, i8** %3
%35 = load i32, i32* %5
%36 = sext i32 %35 to i64
%37 = getelementptr inbounds i8, i8* %34, i64 %36
%38 = load i8, i8* %37
%39 = sext i8 %38 to i32
%40 = call i64 @isdigit(i32 %39)
%41 = icmp ne i64 %40, 0
br i1 %41, label %43, label %42
42: ; preds = %33
store i8 0, i8* %7
br label %43
43: ; preds = %42, %33
br label %44
44: ; preds = %43
%45 = load i32, i32* %5
%46 = add nsw i32 %45, 1
store i32 %46, i32* %5
br label %29
47: ; preds = %29
br label %48
48: ; preds = %47, %22
%49 = load i8, i8* %7
%50 = icmp ne i8 %49, 0
br i1 %50, label %56, label %51
51: ; preds = %48
%52 = load i32, i32* @stderr
%53 = load i32, i32* %4
%54 = call i32 @fprintf(i32 %52, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i32 %53)
%55 = call i32 @exit(i32 2)
unreachable
56: ; preds = %48
ret void
}

LLVM IR (-O2):
@stderr = global i32 0
@.str = [60 x i8] c"Wrong type of parameter for flag -%c. Has to be an integer\0A\00"
define void @check_integer(i8* %0, i32 %1) {
%3 = tail call i32 @strlen(i8* %0)
%4 = load i8, i8* %0
%5 = icmp eq i8 %4, 45
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = sext i8 %4 to i32
%8 = tail call i64 @isdigit(i32 %7)
%9 = icmp eq i64 %8, 0
br i1 %9, label %27, label %10
10: ; preds = %2, %6
%11 = icmp sgt i32 %3, 1
br i1 %11, label %12, label %31
12: ; preds = %10
%13 = zext i32 %3 to i64
br label %14
14: ; preds = %12, %14
%15 = phi i64 [ 1, %12 ], [ %23, %14 ]
%16 = phi i8 [ 1, %12 ], [ %22, %14 ]
%17 = getelementptr inbounds i8, i8* %0, i64 %15
%18 = load i8, i8* %17
%19 = sext i8 %18 to i32
%20 = tail call i64 @isdigit(i32 %19)
%21 = icmp eq i64 %20, 0
%22 = select i1 %21, i8 0, i8 %16
%23 = add nuw nsw i64 %15, 1
%24 = icmp eq i64 %23, %13
br i1 %24, label %25, label %14
25: ; preds = %14
%26 = icmp eq i8 %22, 0
br i1 %26, label %27, label %31
27: ; preds = %6, %25
%28 = load i32, i32* @stderr
%29 = tail call i32 @fprintf(i32 %28, i8* getelementptr inbounds ([60 x i8], [60 x i8]* @.str, i64 0, i64 0), i32 %1)
%30 = tail call i32 @exit(i32 2)
unreachable
31: ; preds = %10, %25
ret void
}