#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*/ isaHexNum(char *);
int /*<<< orphan*/ printf(char *, ...);
scalar_t__ strncmp(char *, char *, int);
char *strtoul(char *, int /*<<< orphan*/ *, int);
int setDbgLevel(int argc, char **argv) {
  {
    if ((argc == 2) && (strncmp(argv[1], "-h", 2) == 0)) {
      printf("Usage:  %-10s ", argv[0]);
      printf("%s\n", "<hex debug mask>\n");
      return (0);
    }
  };
  if (argc != 2) {
    printf("Parm Error: single 'debugLevel' parameter required\n");
    return (0);
  }
  if (!(isaHexNum(argv[1]))) {
    printf("Parm Error: Invalid debugLevel\n");
    return (-1);
  }
  printf("New debug mask is:0x%lx\n", strtoul((argv[1]), NULL, 16));
  return (0);
}


x86 assembly (clang, -O0):
<setDbgLevel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11b2 <setDbgLevel+0x72>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe98(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11b2 <setDbgLevel+0x72>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe7a(%rip),%rdi
lea    0xe77(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1234 <setDbgLevel+0xf4>
cmpl   $0x2,-0x8(%rbp)
je     11d6 <setDbgLevel+0x96>
lea    0xe65(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1234 <setDbgLevel+0xf4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1060 <isaHexNum@plt>
cmp    $0x0,%eax
jne    1206 <setDbgLevel+0xc6>
lea    0xe69(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1234 <setDbgLevel+0xf4>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1050 <strtoul@plt>
mov    %rax,%rsi
lea    0xe56(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<setDbgLevel>:
push   %rbx
cmp    $0x2,%edi
jne    11a5 <setDbgLevel+0x55>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe9c(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11b5 <setDbgLevel+0x65>
mov    0x8(%rbx),%rdi
call   1070 <isaHexNum@plt>
test   %eax,%eax
je     11d6 <setDbgLevel+0x86>
mov    0x8(%rbx),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x10,%edx
call   1060 <strtoul@plt>
lea    0xe8b(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    11e7 <setDbgLevel+0x97>
lea    0xeb0(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
jmp    11e7 <setDbgLevel+0x97>
mov    (%rbx),%rsi
lea    0xe44(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe43(%rip),%rdi
call   1040 <puts@plt>
jmp    11e7 <setDbgLevel+0x97>
lea    0xe60(%rip),%rdi
call   1040 <puts@plt>
mov    $0xffffffff,%ebx
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [3 x i8] c"-h\00"
@.str.1 = [15 x i8] c"Usage: %-10s \00"
@.str.2 = [4 x i8] c"%s\0A\00"
@.str.3 = [18 x i8] c"<hex debug mask>\0A\00"
@.str.4 = [52 x i8] c"Parm Error: single 'debugLevel' parameter required\0A\00"
@.str.5 = [32 x i8] c"Parm Error: Invalid debugLevel\0A\00"
@.str.6 = [25 x i8] c"New debug mask is:0x%lx\0A\00"
define i32 @setDbgLevel(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
store i32 %0, i32* %4
store i8** %1, i8*** %5
%6 = load i32, i32* %4
%7 = icmp eq i32 %6, 2
br i1 %7, label %8, label %20
8: ; preds = %2
%9 = load i8**, i8*** %5
%10 = getelementptr inbounds i8*, i8** %9, i64 1
%11 = load i8*, i8** %10
%12 = call i64 @strncmp(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%13 = icmp eq i64 %12, 0
br i1 %13, label %14, label %20
14: ; preds = %8
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 0
%17 = load i8*, i8** %16
%18 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
store i32 0, i32* %3
br label %39
20: ; preds = %8, %2
%21 = load i32, i32* %4
%22 = icmp ne i32 %21, 2
br i1 %22, label %23, label %25
23: ; preds = %20
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.4, i64 0, i64 0))
store i32 0, i32* %3
br label %39
25: ; preds = %20
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 1
%28 = load i8*, i8** %27
%29 = call i32 @isaHexNum(i8* %28)
%30 = icmp ne i32 %29, 0
br i1 %30, label %33, label %31
31: ; preds = %25
%32 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %39
33: ; preds = %25
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i8* @strtoul(i8* %36, i32* null, i32 16)
%38 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %37)
store i32 0, i32* %3
br label %39
39: ; preds = %33, %31, %23, %14
%40 = load i32, i32* %3
ret i32 %40
}

LLVM IR (-O2):
@.str = [3 x i8] c"-h\00"
@.str.1 = [15 x i8] c"Usage: %-10s \00"
@.str.3 = [18 x i8] c"<hex debug mask>\0A\00"
@.str.6 = [25 x i8] c"New debug mask is:0x%lx\0A\00"
@str = [31 x i8] c"Parm Error: Invalid debugLevel\00"
@str.7 = [51 x i8] c"Parm Error: single 'debugLevel' parameter required\00"
define i32 @setDbgLevel(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %13
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i64 @strncmp(i8* %6, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32 2)
%8 = icmp eq i64 %7, 0
br i1 %8, label %9, label %15
9: ; preds = %4
%10 = load i8*, i8** %1
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str.3, i64 0, i64 0))
br label %25
13: ; preds = %2
%14 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([51 x i8], [51 x i8]* @str.7, i64 0, i64 0))
br label %25
15: ; preds = %4
%16 = load i8*, i8** %5
%17 = tail call i32 @isaHexNum(i8* %16)
%18 = icmp eq i32 %17, 0
br i1 %18, label %19, label %21
19: ; preds = %15
%20 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str, i64 0, i64 0))
br label %25
21: ; preds = %15
%22 = load i8*, i8** %5
%23 = tail call i8* @strtoul(i8* nocapture %22, i32* null, i32 16)
%24 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([25 x i8], [25 x i8]* @.str.6, i64 0, i64 0), i8* %23)
br label %25
25: ; preds = %21, %19, %13, %9
%26 = phi i32 [ 0, %9 ], [ 0, %13 ], [ 0, %21 ], [ -1, %19 ]
ret i32 %26
}