#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 *);
scalar_t__ strcmp(char *, char *);
scalar_t__ validateType(char *, char *, int);
int main(int argc, char *argv[]) {
  if (argc < 2) {
    printf("usage: vyatta-validate-type [-q] <type> <value>\n");
    return 1;
  }
  if (strcmp(argv[1], "-q") == 0) {
    if (validateType(argv[2], argv[3], 1)) {
      return 0;
    }
    return 1;
  }
  if (validateType(argv[1], argv[2], 0)) {
    return 0;
  }
  return 1;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jge    1168 <main+0x38>
lea    0xea9(%rip),%rdi
call   1040 <printf@plt>
movl   $0x1,-0x4(%rbp)
jmp    11f6 <main+0xc6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeba(%rip),%rsi
call   1050 <strcmp@plt>
cmp    $0x0,%rax
jne    11c2 <main+0x92>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rsi
mov    $0x1,%edx
call   1030 <validateType@plt>
cmp    $0x0,%rax
je     11b6 <main+0x86>
movl   $0x0,-0x4(%rbp)
jmp    11f6 <main+0xc6>
movl   $0x1,-0x4(%rbp)
jmp    11f6 <main+0xc6>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rsi
xor    %edx,%edx
call   1030 <validateType@plt>
cmp    $0x0,%rax
je     11ef <main+0xbf>
movl   $0x0,-0x4(%rbp)
jmp    11f6 <main+0xc6>
movl   $0x1,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x1,%edi
jg     1146 <main+0x16>
lea    0xec6(%rip),%rdi
call   1040 <puts@plt>
mov    $0x1,%al
jmp    1182 <main+0x52>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xeac(%rip),%rsi
call   1050 <strcmp@plt>
test   %rax,%rax
je     116a <main+0x3a>
mov    0x8(%rbx),%rdi
mov    0x10(%rbx),%rsi
xor    %edx,%edx
jmp    1177 <main+0x47>
mov    0x10(%rbx),%rdi
mov    0x18(%rbx),%rsi
mov    $0x1,%edx
call   1030 <validateType@plt>
test   %rax,%rax
sete   %al
movzbl %al,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [49 x i8] c"usage: vyatta-validate-type [-q] <type> <value>\0A\00"
@.str.1 = [3 x i8] c"-q\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = call i32 @printf(i8* getelementptr inbounds ([49 x i8], [49 x i8]* @.str, i64 0, i64 0))
store i32 1, i32* %3
br label %38
10: ; preds = %2
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i64 @strcmp(i8* %13, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%15 = icmp eq i64 %14, 0
br i1 %15, label %16, label %27
16: ; preds = %10
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 2
%19 = load i8*, i8** %18
%20 = load i8**, i8*** %5
%21 = getelementptr inbounds i8*, i8** %20, i64 3
%22 = load i8*, i8** %21
%23 = call i64 @validateType(i8* %19, i8* %22, i32 1)
%24 = icmp ne i64 %23, 0
br i1 %24, label %25, label %26
25: ; preds = %16
store i32 0, i32* %3
br label %38
26: ; preds = %16
store i32 1, i32* %3
br label %38
27: ; preds = %10
%28 = load i8**, i8*** %5
%29 = getelementptr inbounds i8*, i8** %28, i64 1
%30 = load i8*, i8** %29
%31 = load i8**, i8*** %5
%32 = getelementptr inbounds i8*, i8** %31, i64 2
%33 = load i8*, i8** %32
%34 = call i64 @validateType(i8* %30, i8* %33, i32 0)
%35 = icmp ne i64 %34, 0
br i1 %35, label %36, label %37
36: ; preds = %27
store i32 0, i32* %3
br label %38
37: ; preds = %27
store i32 1, i32* %3
br label %38
38: ; preds = %37, %36, %26, %25, %8
%39 = load i32, i32* %3
ret i32 %39
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"-q\00"
@str = [48 x i8] c"usage: vyatta-validate-type [-q] <type> <value>\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %6
4: ; preds = %2
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([48 x i8], [48 x i8]* @str, i64 0, i64 0))
br label %24
6: ; preds = %2
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i64 @strcmp(i8* %8, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0))
%10 = icmp eq i64 %9, 0
br i1 %10, label %11, label %18
11: ; preds = %6
%12 = getelementptr inbounds i8*, i8** %1, i64 2
%13 = load i8*, i8** %12
%14 = getelementptr inbounds i8*, i8** %1, i64 3
%15 = load i8*, i8** %14
%16 = tail call i64 @validateType(i8* %13, i8* %15, i32 1)
%17 = icmp eq i64 %16, 0
br label %24
18: ; preds = %6
%19 = load i8*, i8** %7
%20 = getelementptr inbounds i8*, i8** %1, i64 2
%21 = load i8*, i8** %20
%22 = tail call i64 @validateType(i8* %19, i8* %21, i32 0)
%23 = icmp eq i64 %22, 0
br label %24
24: ; preds = %18, %11, %4
%25 = phi i1 [ true, %4 ], [ %17, %11 ], [ %23, %18 ]
%26 = zext i1 %25 to i32
ret i32 %26
}