#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);
scalar_t__ isdigit(int);
int /*<<< orphan*/ printf(char *, char *);
int strlen(char *);
void check_argument(int argc, char **argv) {
  int i = 0;
  if (argc != 3) {
    goto boilout;
  }
  for (i = 0; i < strlen(argv[2]); i++) {
    if (isdigit((int)argv[2][i]) == 0) {
      goto boilout;
    }
  }
  return;
boilout:
  printf("usage: %s filename buffer_size(bytes)\n", argv[0]);
  printf("Ex: %s 1024K_file.dat 4096\n", argv[0]);
  exit(-1);
}


x86 assembly (clang, -O0):
<check_argument>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
movl   $0x0,-0x14(%rbp)
cmpl   $0x3,-0x4(%rbp)
je     1165 <check_argument+0x25>
jmp    11c9 <check_argument+0x89>
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1040 <strlen@plt>
mov    %eax,%ecx
mov    -0x18(%rbp),%eax
cmp    %ecx,%eax
jge    11c3 <check_argument+0x83>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rax
movslq -0x14(%rbp),%rcx
movsbl (%rax,%rcx,1),%edi
call   1030 <isdigit@plt>
cmp    $0x0,%rax
jne    11b0 <check_argument+0x70>
jmp    11c9 <check_argument+0x89>
jmp    11b5 <check_argument+0x75>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    116c <check_argument+0x2c>
add    $0x20,%rsp
pop    %rbp
ret
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe29(%rip),%rdi
call   1050 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe3d(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

x86 assembly (clang, -O2):
<check_argument>:
push   %r14
push   %rbx
push   %rax
mov    %rsi,%r14
cmp    $0x3,%edi
jne    118e <check_argument+0x4e>
mov    0x10(%r14),%rdi
call   1040 <strlen@plt>
test   %eax,%eax
jle    1186 <check_argument+0x46>
xor    %ebx,%ebx
nopl   0x0(%rax,%rax,1)
mov    0x10(%r14),%rax
movsbl (%rax,%rbx,1),%edi
call   1030 <isdigit@plt>
test   %rax,%rax
je     118e <check_argument+0x4e>
add    $0x1,%rbx
mov    0x10(%r14),%rdi
call   1040 <strlen@plt>
cltq
cmp    %rax,%rbx
jl     1160 <check_argument+0x20>
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret
mov    (%r14),%rsi
lea    0xe68(%rip),%rdi
call   1050 <printf@plt>
mov    (%r14),%rsi
lea    0xe80(%rip),%rdi
call   1050 <printf@plt>
mov    $0xffffffff,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"usage: %s filename buffer_size(bytes)\0A\00"
@.str.1 = [28 x i8] c"Ex: %s 1024K_file.dat 4096\0A\00"
define void @check_argument(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 0, i32* %5
%6 = load i32, i32* %3
%7 = icmp ne i32 %6, 3
br i1 %7, label %8, label %9
8: ; preds = %2
br label %34
9: ; preds = %2
store i32 0, i32* %5
br label %10
10: ; preds = %30, %9
%11 = load i32, i32* %5
%12 = load i8**, i8*** %4
%13 = getelementptr inbounds i8*, i8** %12, i64 2
%14 = load i8*, i8** %13
%15 = call i32 @strlen(i8* %14)
%16 = icmp slt i32 %11, %15
br i1 %16, label %17, label %33
17: ; preds = %10
%18 = load i8**, i8*** %4
%19 = getelementptr inbounds i8*, i8** %18, i64 2
%20 = load i8*, i8** %19
%21 = load i32, i32* %5
%22 = sext i32 %21 to i64
%23 = getelementptr inbounds i8, i8* %20, i64 %22
%24 = load i8, i8* %23
%25 = sext i8 %24 to i32
%26 = call i64 @isdigit(i32 %25)
%27 = icmp eq i64 %26, 0
br i1 %27, label %28, label %29
28: ; preds = %17
br label %34
29: ; preds = %17
br label %30
30: ; preds = %29
%31 = load i32, i32* %5
%32 = add nsw i32 %31, 1
store i32 %32, i32* %5
br label %10
33: ; preds = %10
ret void
34: ; preds = %28, %8
%35 = load i8**, i8*** %4
%36 = getelementptr inbounds i8*, i8** %35, i64 0
%37 = load i8*, i8** %36
%38 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %37)
%39 = load i8**, i8*** %4
%40 = getelementptr inbounds i8*, i8** %39, i64 0
%41 = load i8*, i8** %40
%42 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %41)
%43 = call i32 @exit(i32 -1)
unreachable
}

LLVM IR (-O2):
@.str = [39 x i8] c"usage: %s filename buffer_size(bytes)\0A\00"
@.str.1 = [28 x i8] c"Ex: %s 1024K_file.dat 4096\0A\00"
define void @check_argument(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
br i1 %3, label %4, label %24
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 2
%6 = load i8*, i8** %5
%7 = tail call i32 @strlen(i8* %6)
%8 = icmp sgt i32 %7, 0
br i1 %8, label %14, label %23
9: ; preds = %14
%10 = load i8*, i8** %5
%11 = tail call i32 @strlen(i8* %10)
%12 = sext i32 %11 to i64
%13 = icmp slt i64 %22, %12
br i1 %13, label %14, label %23
14: ; preds = %4, %9
%15 = phi i64 [ %22, %9 ], [ 0, %4 ]
%16 = load i8*, i8** %5
%17 = getelementptr inbounds i8, i8* %16, 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 = add nuw nsw i64 %15, 1
br i1 %21, label %24, label %9
23: ; preds = %9, %4
ret void
24: ; preds = %14, %2
%25 = load i8*, i8** %1
%26 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i8* %25)
%27 = load i8*, i8** %1
%28 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.1, i64 0, i64 0), i8* %27)
%29 = tail call i32 @exit(i32 -1)
unreachable
}