#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 EXIT_SUCCESS;
int /*<<< orphan*/ check_intInput(int *);
int nth_position(int, int);
int /*<<< orphan*/ printf(char *, ...);
int main() {
  printf("Enter decimal: ");
  int n;
  check_intInput(&n);
  int resultFirstPos = nth_position(n, 1);
  printf("%d bit position of %d is %d\n", 1, n, resultFirstPos);
  int resultThirdPos = nth_position(n, 3);
  printf("%d bit position of %d is %d", 3, n, resultThirdPos);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1030 <check_intInput@plt>
mov    -0x8(%rbp),%edi
mov    $0x1,%esi
call   1050 <nth_position@plt>
mov    %eax,-0xc(%rbp)
mov    -0x8(%rbp),%edx
mov    -0xc(%rbp),%ecx
lea    0xe9d(%rip),%rdi
mov    $0x1,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x8(%rbp),%edi
mov    $0x3,%esi
call   1050 <nth_position@plt>
mov    %eax,-0x10(%rbp)
mov    -0x8(%rbp),%edx
mov    -0x10(%rbp),%ecx
lea    0xe91(%rip),%rdi
mov    $0x3,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e31(%rip),%rax
mov    (%rax),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
lea    0xec8(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0x4(%rsp),%rdi
call   1030 <check_intInput@plt>
mov    0x4(%rsp),%edi
mov    $0x1,%esi
call   1050 <nth_position@plt>
mov    0x4(%rsp),%edx
lea    0xeae(%rip),%rdi
mov    $0x1,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x4(%rsp),%edi
mov    $0x3,%esi
call   1050 <nth_position@plt>
mov    0x4(%rsp),%edx
lea    0xea4(%rip),%rdi
mov    $0x3,%esi
mov    %eax,%ecx
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2e42(%rip),%rax
mov    (%rax),%eax
pop    %rcx
ret

LLVM IR (-O0):
@.str = [16 x i8] c"Enter decimal: \00"
@.str.1 = [29 x i8] c"%d bit position of %d is %d\0A\00"
@.str.2 = [28 x i8] c"%d bit position of %d is %d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
store i32 0, i32* %1
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%6 = call i32 @check_intInput(i32* %2)
%7 = load i32, i32* %2
%8 = call i32 @nth_position(i32 %7, i32 1)
store i32 %8, i32* %3
%9 = load i32, i32* %2
%10 = load i32, i32* %3
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %9, i32 %10)
%12 = load i32, i32* %2
%13 = call i32 @nth_position(i32 %12, i32 3)
store i32 %13, i32* %4
%14 = load i32, i32* %2
%15 = load i32, i32* %4
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 %14, i32 %15)
%17 = load i32, i32* @EXIT_SUCCESS
ret i32 %17
}

LLVM IR (-O2):
@.str = [16 x i8] c"Enter decimal: \00"
@.str.1 = [29 x i8] c"%d bit position of %d is %d\0A\00"
@.str.2 = [28 x i8] c"%d bit position of %d is %d\00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0))
%3 = bitcast i32* %1 to i8*
%4 = call i32 @check_intInput(i32* %1)
%5 = load i32, i32* %1
%6 = call i32 @nth_position(i32 %5, i32 1)
%7 = load i32, i32* %1
%8 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.1, i64 0, i64 0), i32 1, i32 %7, i32 %6)
%9 = load i32, i32* %1
%10 = call i32 @nth_position(i32 %9, i32 3)
%11 = load i32, i32* %1
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i32 3, i32 %11, i32 %10)
%13 = load i32, i32* @EXIT_SUCCESS
ret i32 %13
}