#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*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *);
main(void) {
  unsigned int val, temp = 0;
  int ii, flag = 0;
  printf("Enter an unsingned integer in Hex format\n");
  scanf("%x", &val);
  for (ii = 32; ii > 0; ii--) {
    temp = val >> (ii - 1);
    temp &= 0x1;
    if (!flag) {
      if (temp)
        flag = 1;
    }
    if (flag)
      printf("%x", temp);
  }
  printf("\n");
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0xc(%rbp)
movl   $0x0,-0x14(%rbp)
lea    0xebc(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xed8(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1040 <scanf@plt>
movl   $0x20,-0x10(%rbp)
cmpl   $0x0,-0x10(%rbp)
jle    11d1 <main+0xb1>
mov    -0x8(%rbp),%eax
mov    -0x10(%rbp),%ecx
sub    $0x1,%ecx
shr    %cl,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%eax
and    $0x1,%eax
mov    %eax,-0xc(%rbp)
cmpl   $0x0,-0x14(%rbp)
jne    11a3 <main+0x83>
cmpl   $0x0,-0xc(%rbp)
je     119e <main+0x7e>
movl   $0x1,-0x14(%rbp)
jmp    11a3 <main+0x83>
cmpl   $0x0,-0x14(%rbp)
je     11be <main+0x9e>
mov    -0xc(%rbp),%esi
lea    0xe73(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    11c3 <main+0xa3>
mov    -0x10(%rbp),%eax
add    $0xffffffff,%eax
mov    %eax,-0x10(%rbp)
jmp    1162 <main+0x42>
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
lea    0xeb5(%rip),%rdi
call   1040 <puts@plt>
lea    0xea6(%rip),%r14
lea    0x4(%rsp),%rsi
mov    %r14,%rdi
call   1060 <scanf@plt>
mov    $0x21,%ebx
mov    $0x1,%r15d
xor    %ebp,%ebp
jmp    1188 <main+0x48>
cs nopw 0x0(%rax,%rax,1)
add    $0xffffffff,%ebx
cmp    $0x1,%ebx
jbe    11b7 <main+0x77>
mov    %ebp,%eax
mov    0x4(%rsp),%edx
lea    -0x2(%rbx),%ecx
mov    %edx,%esi
shr    %cl,%esi
movzbl %cl,%ecx
bt     %ecx,%edx
cmovb  %r15d,%ebp
test   %eax,%eax
cmovne %eax,%ebp
test   %ebp,%ebp
je     1180 <main+0x40>
and    $0x1,%esi
mov    %r14,%rdi
xor    %eax,%eax
call   1050 <printf@plt>
jmp    1180 <main+0x40>
mov    $0xa,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [42 x i8] c"Enter an unsingned integer in Hex format\0A\00"
@.str.1 = [3 x i8] c"%x\00"
@.str.2 = [2 x i8] c"\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %3
store i32 0, i32* %5
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([42 x i8], [42 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %2)
store i32 32, i32* %4
br label %8
8: ; preds = %32, %0
%9 = load i32, i32* %4
%10 = icmp sgt i32 %9, 0
br i1 %10, label %11, label %35
11: ; preds = %8
%12 = load i32, i32* %2
%13 = load i32, i32* %4
%14 = sub nsw i32 %13, 1
%15 = lshr i32 %12, %14
store i32 %15, i32* %3
%16 = load i32, i32* %3
%17 = and i32 %16, 1
store i32 %17, i32* %3
%18 = load i32, i32* %5
%19 = icmp ne i32 %18, 0
br i1 %19, label %25, label %20
20: ; preds = %11
%21 = load i32, i32* %3
%22 = icmp ne i32 %21, 0
br i1 %22, label %23, label %24
23: ; preds = %20
store i32 1, i32* %5
br label %24
24: ; preds = %23, %20
br label %25
25: ; preds = %24, %11
%26 = load i32, i32* %5
%27 = icmp ne i32 %26, 0
br i1 %27, label %28, label %31
28: ; preds = %25
%29 = load i32, i32* %3
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %29)
br label %31
31: ; preds = %28, %25
br label %32
32: ; preds = %31
%33 = load i32, i32* %4
%34 = add nsw i32 %33, -1
store i32 %34, i32* %4
br label %8
35: ; preds = %8
%36 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.2, i64 0, i64 0))
%37 = load i32, i32* %1
ret i32 %37
}

LLVM IR (-O2):
@.str.1 = [3 x i8] c"%x\00"
@str = [41 x i8] c"Enter an unsingned integer in Hex format\00"
define i32 @main() {
%1 = alloca i32
%2 = bitcast i32* %1 to i8*
%3 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([41 x i8], [41 x i8]* @str, i64 0, i64 0))
%4 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %1)
br label %5
5: ; preds = %0, %19
%6 = phi i32 [ 0, %0 ], [ %15, %19 ]
%7 = phi i32 [ 32, %0 ], [ %9, %19 ]
%8 = load i32, i32* %1
%9 = add nsw i32 %7, -1
%10 = lshr i32 %8, %9
%11 = and i32 %10, 1
%12 = icmp eq i32 %6, 0
%13 = icmp ne i32 %11, 0
%14 = select i1 %12, i1 %13, i1 false
%15 = select i1 %14, i32 1, i32 %6
%16 = icmp eq i32 %15, 0
br i1 %16, label %19, label %17
17: ; preds = %5
%18 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32 %11)
br label %19
19: ; preds = %5, %17
%20 = icmp ugt i32 %7, 1
br i1 %20, label %5, label %21
21: ; preds = %19
%22 = call i32 @putchar(i32 10)
ret i32 0
}