#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 */
char *get_desc(unsigned int);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ sscanf(char *, char *, unsigned int *);
int main(int c, char **v) {
  unsigned int error, desc, module, summary, level;
  sscanf(v[1], "%08x", &error);
  printf("Code: %08x\n", error);
  desc = error & 0b1111111111;
  module = (error >> 10) & 0b11111111;
  summary = (error >> 21) & 0b111111;
  level = (error >> 27) & 0b11111;
  printf("Desc: %s (%u)\n", get_desc(desc), desc);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xeab(%rip),%rsi
lea    -0x14(%rbp),%rdx
call   1050 <sscanf@plt>
mov    -0x14(%rbp),%esi
lea    0xe9d(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x14(%rbp),%eax
and    $0x3ff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%eax
shr    $0xa,%eax
and    $0xff,%eax
mov    %eax,-0x1c(%rbp)
mov    -0x14(%rbp),%eax
shr    $0x15,%eax
and    $0x3f,%eax
mov    %eax,-0x20(%rbp)
mov    -0x14(%rbp),%eax
shr    $0x1b,%eax
and    $0x1f,%eax
mov    %eax,-0x24(%rbp)
mov    -0x18(%rbp),%edi
call   1040 <get_desc@plt>
mov    %rax,%rsi
mov    -0x18(%rbp),%edx
lea    0xe5c(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x8(%rsi),%rdi
lea    0xec0(%rip),%rsi
lea    0xc(%rsp),%rdx
call   1050 <sscanf@plt>
mov    0xc(%rsp),%esi
lea    0xeb0(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
mov    $0x3ff,%ebx
and    0xc(%rsp),%ebx
mov    %ebx,%edi
call   1040 <get_desc@plt>
lea    0xe9e(%rip),%rdi
mov    %rax,%rsi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [5 x i8] c"%08x\00"
@.str.1 = [12 x i8] c"Code: %08x\0A\00"
@.str.2 = [15 x i8] c"Desc: %s (%u)\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32 @sscanf(i8* %13, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %6)
%15 = load i32, i32* %6
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %6
%18 = and i32 %17, 1023
store i32 %18, i32* %7
%19 = load i32, i32* %6
%20 = lshr i32 %19, 10
%21 = and i32 %20, 255
store i32 %21, i32* %8
%22 = load i32, i32* %6
%23 = lshr i32 %22, 21
%24 = and i32 %23, 63
store i32 %24, i32* %9
%25 = load i32, i32* %6
%26 = lshr i32 %25, 27
%27 = and i32 %26, 31
store i32 %27, i32* %10
%28 = load i32, i32* %7
%29 = call i8* @get_desc(i32 %28)
%30 = load i32, i32* %7
%31 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %29, i32 %30)
ret i32 0
}

LLVM IR (-O2):
@.str = [5 x i8] c"%08x\00"
@.str.1 = [12 x i8] c"Code: %08x\0A\00"
@.str.2 = [15 x i8] c"Desc: %s (%u)\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = bitcast i32* %3 to i8*
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = call i32 @sscanf(i8* %6, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str, i64 0, i64 0), i32* %3)
%8 = load i32, i32* %3
%9 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.1, i64 0, i64 0), i32 %8)
%10 = load i32, i32* %3
%11 = and i32 %10, 1023
%12 = call i8* @get_desc(i32 %11)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i8* %12, i32 %11)
ret i32 0
}