#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*/ printf(char *, char const *, ...);
int check_arg(char **arg, const char *flag, int num, int argc) {
  if (num >= argc) {
    printf("Missing argument to \"%s\" flag\n", flag);
    return 1;
  }
  if (arg[num][0] == '-') {
    printf("Incorrect argument to \"%s\" flag: %s\n", flag, arg[num]);
    return 1;
  }
  return 0;
}


x86 assembly (clang, -O0):
<check_arg>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x10(%rbp)
mov    %rsi,-0x18(%rbp)
mov    %edx,-0x1c(%rbp)
mov    %ecx,-0x20(%rbp)
mov    -0x1c(%rbp),%eax
cmp    -0x20(%rbp),%eax
jl     1150 <check_arg+0x40>
mov    -0x18(%rbp),%rsi
lea    0xec3(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1199 <check_arg+0x89>
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
movsbl (%rax),%eax
cmp    $0x2d,%eax
jne    1192 <check_arg+0x82>
mov    -0x18(%rbp),%rsi
mov    -0x10(%rbp),%rax
movslq -0x1c(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xea0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    1199 <check_arg+0x89>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<check_arg>:
push   %rax
cmp    %ecx,%edx
jge    1133 <check_arg+0x23>
movslq %edx,%rax
mov    (%rdi,%rax,8),%rdx
xor    %eax,%eax
cmpb   $0x2d,(%rdx)
jne    1146 <check_arg+0x36>
lea    0xef5(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
jmp    1141 <check_arg+0x31>
lea    0xec6(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x1,%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [31 x i8] c"Missing argument to \22%s\22 flag\0A\00"
@.str.1 = [37 x i8] c"Incorrect argument to \22%s\22 flag: %s\0A\00"
define i32 @check_arg(i8** %0, i8* %1, i32 %2, i32 %3) {
%5 = alloca i32
%6 = alloca i8**
%7 = alloca i8*
%8 = alloca i32
%9 = alloca i32
store i8** %0, i8*** %6
store i8* %1, i8** %7
store i32 %2, i32* %8
store i32 %3, i32* %9
%10 = load i32, i32* %8
%11 = load i32, i32* %9
%12 = icmp sge i32 %10, %11
br i1 %12, label %13, label %16
13: ; preds = %4
%14 = load i8*, i8** %7
%15 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %14)
store i32 1, i32* %5
br label %35
16: ; preds = %4
%17 = load i8**, i8*** %6
%18 = load i32, i32* %8
%19 = sext i32 %18 to i64
%20 = getelementptr inbounds i8*, i8** %17, i64 %19
%21 = load i8*, i8** %20
%22 = getelementptr inbounds i8, i8* %21, i64 0
%23 = load i8, i8* %22
%24 = sext i8 %23 to i32
%25 = icmp eq i32 %24, 45
br i1 %25, label %26, label %34
26: ; preds = %16
%27 = load i8*, i8** %7
%28 = load i8**, i8*** %6
%29 = load i32, i32* %8
%30 = sext i32 %29 to i64
%31 = getelementptr inbounds i8*, i8** %28, i64 %30
%32 = load i8*, i8** %31
%33 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %27, i8* %32)
store i32 1, i32* %5
br label %35
34: ; preds = %16
store i32 0, i32* %5
br label %35
35: ; preds = %34, %26, %13
%36 = load i32, i32* %5
ret i32 %36
}

LLVM IR (-O2):
@.str = [31 x i8] c"Missing argument to \22%s\22 flag\0A\00"
@.str.1 = [37 x i8] c"Incorrect argument to \22%s\22 flag: %s\0A\00"
define i32 @check_arg(i8** nocapture %0, i8* %1, i32 %2, i32 %3) {
%5 = icmp slt i32 %2, %3
br i1 %5, label %8, label %6
6: ; preds = %4
%7 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([31 x i8], [31 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %16
8: ; preds = %4
%9 = sext i32 %2 to i64
%10 = getelementptr inbounds i8*, i8** %0, i64 %9
%11 = load i8*, i8** %10
%12 = load i8, i8* %11
%13 = icmp eq i8 %12, 45
br i1 %13, label %14, label %16
14: ; preds = %8
%15 = tail call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([37 x i8], [37 x i8]* @.str.1, i64 0, i64 0), i8* %1, i8* %11)
br label %16
16: ; preds = %8, %14, %6
%17 = phi i32 [ 1, %6 ], [ 1, %14 ], [ 0, %8 ]
ret i32 %17
}