#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*/ logmsg(int, char *);
size_t strlen(char *);
void validate_arguments(int argc, char *argv[]) {
  if (argc < 2) {
    logmsg(1, "Missing arguments");
    exit(-1);
  }
  size_t argLen = strlen(argv[1]);
  if (argLen % 2 != 0) {
    logmsg(1, "Not a valid hexadecimal string, missing one character?");
    exit(-2);
  }
}


x86 assembly (clang, -O0):
<validate_arguments>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %edi,-0x4(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x4(%rbp)
jge    1164 <validate_arguments+0x34>
mov    $0x1,%edi
lea    0xeab(%rip),%rsi
call   1040 <logmsg@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
and    $0x1,%rax
cmp    $0x0,%rax
je     11a2 <validate_arguments+0x72>
mov    $0x1,%edi
lea    0xe7f(%rip),%rsi
call   1040 <logmsg@plt>
mov    $0xfffffffe,%edi
call   1050 <exit@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<validate_arguments>:
push   %rax
cmp    $0x1,%edi
jle    1145 <validate_arguments+0x15>
mov    0x8(%rsi),%rdi
call   1030 <strlen@plt>
test   $0x1,%al
jne    1160 <validate_arguments+0x30>
pop    %rax
ret
lea    0xeb4(%rip),%rsi
mov    $0x1,%edi
call   1040 <logmsg@plt>
mov    $0xffffffff,%edi
call   1050 <exit@plt>
lea    0xeab(%rip),%rsi
mov    $0x1,%edi
call   1040 <logmsg@plt>
mov    $0xfffffffe,%edi
call   1050 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Missing arguments\00"
@.str.1 = [55 x i8] c"Not a valid hexadecimal string, missing one character?\00"
define void @validate_arguments(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i8**
%5 = alloca i64
store i32 %0, i32* %3
store i8** %1, i8*** %4
%6 = load i32, i32* %3
%7 = icmp slt i32 %6, 2
br i1 %7, label %8, label %11
8: ; preds = %2
%9 = call i32 @logmsg(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%10 = call i32 @exit(i32 -1)
unreachable
11: ; preds = %2
%12 = load i8**, i8*** %4
%13 = getelementptr inbounds i8*, i8** %12, i64 1
%14 = load i8*, i8** %13
%15 = call i64 @strlen(i8* %14)
store i64 %15, i64* %5
%16 = load i64, i64* %5
%17 = urem i64 %16, 2
%18 = icmp ne i64 %17, 0
br i1 %18, label %19, label %22
19: ; preds = %11
%20 = call i32 @logmsg(i32 1, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%21 = call i32 @exit(i32 -2)
unreachable
22: ; preds = %11
ret void
}

LLVM IR (-O2):
@.str = [18 x i8] c"Missing arguments\00"
@.str.1 = [55 x i8] c"Not a valid hexadecimal string, missing one character?\00"
define void @validate_arguments(i32 %0, i8** nocapture %1) {
%3 = icmp slt i32 %0, 2
br i1 %3, label %4, label %7
4: ; preds = %2
%5 = tail call i32 @logmsg(i32 1, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%6 = tail call i32 @exit(i32 -1)
unreachable
7: ; preds = %2
%8 = getelementptr inbounds i8*, i8** %1, i64 1
%9 = load i8*, i8** %8
%10 = tail call i64 @strlen(i8* dereferenceable(1) %9)
%11 = and i64 %10, 1
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %7
%14 = tail call i32 @logmsg(i32 1, i8* getelementptr inbounds ([55 x i8], [55 x i8]* @.str.1, i64 0, i64 0))
%15 = tail call i32 @exit(i32 -2)
unreachable
16: ; preds = %7
ret void
}