#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 */
typedef int /*<<< orphan*/ uint64_t;

/* Variables and functions */
int /*<<< orphan*/ exit(int);
int /*<<< orphan*/ get_cgroupid(char *);
int /*<<< orphan*/ printf(char *, unsigned char, ...);
scalar_t__ strcmp(char *, char *);
int /*<<< orphan*/ usage();
int main(int argc, char **argv) {
  uint64_t cgroupid;
  int i;
  if (argc != 3 || (strcmp(argv[1], "number") != 0 && strcmp(argv[1], "hex"))) {
    usage();
    exit(1);
  }
  cgroupid = get_cgroupid(argv[2]);
  if (strcmp(argv[1], "number") == 0)
    printf("%lu\n", cgroupid);
  if (strcmp(argv[1], "hex") == 0) {
    for (i = 0; i < 8; i++) {
      printf("%02x%s", ((unsigned char *)&cgroupid)[i], i == 7 ? "\n" : " ");
    }
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x3,-0x8(%rbp)
jne    11ac <main+0x5c>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe81(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11bd <main+0x6d>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe6a(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
je     11bd <main+0x6d>
mov    $0x0,%al
call   1050 <usage@plt>
mov    $0x1,%edi
call   1060 <exit@plt>
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
call   1070 <get_cgroupid@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe24(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    11ff <main+0xaf>
mov    -0x14(%rbp),%eax
lea    0xe16(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xdf9(%rip),%rsi
call   1040 <strcmp@plt>
cmp    $0x0,%rax
jne    1272 <main+0x122>
movl   $0x0,-0x18(%rbp)
cmpl   $0x8,-0x18(%rbp)
jge    126d <main+0x11d>
movslq -0x18(%rbp),%rax
mov    -0x14(%rbp,%rax,1),%al
mov    -0x18(%rbp),%esi
lea    0xdd7(%rip),%rdx
lea    0xdc7(%rip),%rcx
cmp    $0x7,%esi
cmove  %rcx,%rdx
lea    0xdbb(%rip),%rdi
movzbl %al,%esi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x18(%rbp)
jmp    1224 <main+0xd4>
jmp    1272 <main+0x122>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
cmp    $0x3,%edi
jne    128c <main+0x13c>
mov    %rsi,%rbx
mov    0x8(%rsi),%rdi
lea    0xe91(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
je     1192 <main+0x42>
mov    0x8(%rbx),%rdi
lea    0xe83(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    128c <main+0x13c>
mov    0x10(%rbx),%rdi
call   1070 <get_cgroupid@plt>
mov    %eax,%ebp
mov    0x8(%rbx),%rdi
lea    0xe58(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    11c4 <main+0x74>
movzbl %bpl,%esi
lea    0xe4e(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x8(%rbx),%rdi
lea    0xe38(%rip),%rsi
call   1040 <strcmp@plt>
test   %rax,%rax
jne    1281 <main+0x131>
mov    %ebp,%ebx
shr    $0x8,%ebx
mov    %ebp,%r12d
shr    $0x10,%r12d
mov    %ebp,%r15d
shr    $0x18,%r15d
movzbl %bpl,%esi
lea    0xe15(%rip),%rbp
lea    0xe15(%rip),%r14
mov    %rbp,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
movzbl %bl,%esi
mov    %rbp,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
movzbl %r12b,%esi
mov    %rbp,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
movzbl %r15b,%esi
mov    %rbp,%rdi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
mov    %rbp,%rdi
xor    %esi,%esi
mov    %r14,%rdx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xd99(%rip),%rdx
mov    %rbp,%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret
xor    %eax,%eax
call   1050 <usage@plt>
mov    $0x1,%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [7 x i8] c"number\00"
@.str.1 = [4 x i8] c"hex\00"
@.str.2 = [5 x i8] c"%lu\0A\00"
@.str.3 = [7 x i8] c"%02x%s\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [2 x i8] c" \00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i32, i32* %4
%9 = icmp ne i32 %8, 3
br i1 %9, label %22, label %10
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 ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%15 = icmp ne i64 %14, 0
br i1 %15, label %16, label %25
16: ; preds = %10
%17 = load i8**, i8*** %5
%18 = getelementptr inbounds i8*, i8** %17, i64 1
%19 = load i8*, i8** %18
%20 = call i64 @strcmp(i8* %19, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %25
22: ; preds = %16, %2
%23 = call i32 (...) @usage()
%24 = call i32 @exit(i32 1)
unreachable
25: ; preds = %16, %10
%26 = load i8**, i8*** %5
%27 = getelementptr inbounds i8*, i8** %26, i64 2
%28 = load i8*, i8** %27
%29 = call i32 @get_cgroupid(i8* %28)
store i32 %29, i32* %6
%30 = load i8**, i8*** %5
%31 = getelementptr inbounds i8*, i8** %30, i64 1
%32 = load i8*, i8** %31
%33 = call i64 @strcmp(i8* %32, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%34 = icmp eq i64 %33, 0
br i1 %34, label %35, label %39
35: ; preds = %25
%36 = load i32, i32* %6
%37 = trunc i32 %36 to i8
%38 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %37)
br label %39
39: ; preds = %35, %25
%40 = load i8**, i8*** %5
%41 = getelementptr inbounds i8*, i8** %40, i64 1
%42 = load i8*, i8** %41
%43 = call i64 @strcmp(i8* %42, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%44 = icmp eq i64 %43, 0
br i1 %44, label %45, label %64
45: ; preds = %39
store i32 0, i32* %7
br label %46
46: ; preds = %60, %45
%47 = load i32, i32* %7
%48 = icmp slt i32 %47, 8
br i1 %48, label %49, label %63
49: ; preds = %46
%50 = bitcast i32* %6 to i8*
%51 = load i32, i32* %7
%52 = sext i32 %51 to i64
%53 = getelementptr inbounds i8, i8* %50, i64 %52
%54 = load i8, i8* %53
%55 = load i32, i32* %7
%56 = icmp eq i32 %55, 7
%57 = zext i1 %56 to i64
%58 = select i1 %56, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0)
%59 = call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %54, i8* %58)
br label %60
60: ; preds = %49
%61 = load i32, i32* %7
%62 = add nsw i32 %61, 1
store i32 %62, i32* %7
br label %46
63: ; preds = %46
br label %64
64: ; preds = %63, %39
ret i32 0
}

LLVM IR (-O2):
@.str = [7 x i8] c"number\00"
@.str.1 = [4 x i8] c"hex\00"
@.str.2 = [5 x i8] c"%lu\0A\00"
@.str.3 = [7 x i8] c"%02x%s\00"
@.str.4 = [2 x i8] c"\0A\00"
@.str.5 = [2 x i8] c" \00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 3
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 @strcmp(i8* %6, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%8 = icmp eq i64 %7, 0
br i1 %8, label %16, label %9
9: ; preds = %4
%10 = load i8*, i8** %5
%11 = tail call i64 @strcmp(i8* %10, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%12 = icmp eq i64 %11, 0
br i1 %12, label %16, label %13
13: ; preds = %9, %2
%14 = tail call i32 (...) @usage()
%15 = tail call i32 @exit(i32 1)
unreachable
16: ; preds = %9, %4
%17 = getelementptr inbounds i8*, i8** %1, i64 2
%18 = load i8*, i8** %17
%19 = tail call i32 @get_cgroupid(i8* %18)
%20 = trunc i32 %19 to i8
%21 = lshr i32 %19, 8
%22 = trunc i32 %21 to i8
%23 = lshr i32 %19, 16
%24 = trunc i32 %23 to i8
%25 = lshr i32 %19, 24
%26 = trunc i32 %25 to i8
%27 = load i8*, i8** %5
%28 = tail call i64 @strcmp(i8* %27, i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str, i64 0, i64 0))
%29 = icmp eq i64 %28, 0
br i1 %29, label %30, label %32
30: ; preds = %16
%31 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0), i8 zeroext %20)
br label %32
32: ; preds = %30, %16
%33 = load i8*, i8** %5
%34 = tail call i64 @strcmp(i8* %33, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0))
%35 = icmp eq i64 %34, 0
br i1 %35, label %36, label %45
36: ; preds = %32
%37 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %20, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%38 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %22, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%39 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %24, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%40 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8 zeroext %26, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%41 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8 zeroext poison, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%42 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8 zeroext poison, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%43 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8 zeroext poison, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.5, i64 0, i64 0))
%44 = tail call i32 (i8*, i8, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.3, i64 0, i64 0), i8 zeroext poison, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
br label %45
45: ; preds = %36, %32
ret i32 0
}