#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 *, ...);
char *rtv_get_dbgmask();
int /*<<< orphan*/ rtv_set_dbgmask(int /*<<< orphan*/);
scalar_t__ strncmp(char *, char *, int);
int /*<<< orphan*/ strtoul(char *, int /*<<< orphan*/ *, int);
int ciSetDbgLevel(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 hex mask\n");
    return (-1);
  }
  rtv_set_dbgmask(strtoul((argv[1]), NULL, 16));
  printf("New debug mask is:0x%08lx\n", rtv_get_dbgmask());
  return (0);
}


x86 assembly (clang, -O0):
<ciSetDbgLevel>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    11d2 <ciSetDbgLevel+0x72>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe78(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
cmp    $0x0,%rax
jne    11d2 <ciSetDbgLevel+0x72>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe59(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe5a(%rip),%rdi
lea    0xe57(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1262 <ciSetDbgLevel+0x102>
cmpl   $0x2,-0x8(%rbp)
je     11f6 <ciSetDbgLevel+0x96>
lea    0xe45(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    1262 <ciSetDbgLevel+0x102>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1080 <isaHexNum@plt>
cmp    $0x0,%eax
jne    1226 <ciSetDbgLevel+0xc6>
lea    0xe49(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0xffffffff,-0x4(%rbp)
jmp    1262 <ciSetDbgLevel+0x102>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
xor    %eax,%eax
mov    %eax,%esi
mov    $0x10,%edx
call   1060 <strtoul@plt>
mov    %eax,%edi
call   1050 <rtv_set_dbgmask@plt>
mov    $0x0,%al
call   1070 <rtv_get_dbgmask@plt>
mov    %rax,%rsi
lea    0xe26(%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):
<ciSetDbgLevel>:
push   %rbx
cmp    $0x2,%edi
jne    11d3 <ciSetDbgLevel+0x63>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe7c(%rip),%rsi
mov    $0x2,%edx
call   1030 <strncmp@plt>
test   %rax,%rax
je     11e3 <ciSetDbgLevel+0x73>
mov    0x8(%rbx),%rdi
call   1090 <isaHexNum@plt>
test   %eax,%eax
je     1204 <ciSetDbgLevel+0x94>
mov    0x8(%rbx),%rdi
xor    %ebx,%ebx
xor    %esi,%esi
mov    $0x10,%edx
call   1070 <strtoul@plt>
mov    %eax,%edi
call   1060 <rtv_set_dbgmask@plt>
xor    %eax,%eax
call   1080 <rtv_get_dbgmask@plt>
lea    0xe5d(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1215 <ciSetDbgLevel+0xa5>
lea    0xe82(%rip),%rdi
call   1040 <puts@plt>
xor    %ebx,%ebx
jmp    1215 <ciSetDbgLevel+0xa5>
mov    (%rbx),%rsi
lea    0xe16(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe15(%rip),%rdi
call   1040 <puts@plt>
jmp    1215 <ciSetDbgLevel+0xa5>
lea    0xe34(%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 = [30 x i8] c"Parm Error: Invalid hex mask\0A\00"
@.str.6 = [27 x i8] c"New debug mask is:0x%08lx\0A\00"
define i32 @ciSetDbgLevel(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 %41
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 %41
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 ([30 x i8], [30 x i8]* @.str.5, i64 0, i64 0))
store i32 -1, i32* %3
br label %41
33: ; preds = %25
%34 = load i8**, i8*** %5
%35 = getelementptr inbounds i8*, i8** %34, i64 1
%36 = load i8*, i8** %35
%37 = call i32 @strtoul(i8* %36, i32* null, i32 16)
%38 = call i32 @rtv_set_dbgmask(i32 %37)
%39 = call i8* (...) @rtv_get_dbgmask()
%40 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %39)
store i32 0, i32* %3
br label %41
41: ; preds = %33, %31, %23, %14
%42 = load i32, i32* %3
ret i32 %42
}

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 = [27 x i8] c"New debug mask is:0x%08lx\0A\00"
@str = [29 x i8] c"Parm Error: Invalid hex mask\00"
@str.7 = [51 x i8] c"Parm Error: single 'debugLevel' parameter required\00"
define i32 @ciSetDbgLevel(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 %27
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 %27
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 ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
br label %27
21: ; preds = %15
%22 = load i8*, i8** %5
%23 = tail call i32 @strtoul(i8* nocapture %22, i32* null, i32 16)
%24 = tail call i32 @rtv_set_dbgmask(i32 %23)
%25 = tail call i8* (...) @rtv_get_dbgmask()
%26 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.6, i64 0, i64 0), i8* %25)
br label %27
27: ; preds = %21, %19, %13, %9
%28 = phi i32 [ 0, %9 ], [ 0, %13 ], [ 0, %21 ], [ -1, %19 ]
ret i32 %28
}