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

/* Variables and functions */
int ULONG_MAX;
char *ctime(int /*<<< orphan*/ *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int highestOneBitPosition(unsigned long);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
main() {
  unsigned long exp_max_long = ULONG_MAX + 2;
  unsigned long extimated_ulong = 0;
  int long_bits = 0;
  time_t mytime;
  printf("Test of unsigned long size:\r\n");
  printf("\nC compiler max: %ld\r\n", exp_max_long);
  printf("\nSizeof unsigned long: %d\r\n", sizeof(exp_max_long));
  extimated_ulong = 1;
  do {
    exp_max_long = extimated_ulong;
    long_bits = highestOneBitPosition(extimated_ulong);
    extimated_ulong *= 2;
  } while (extimated_ulong > exp_max_long);
  printf("\nExtimated size: %d bit\r\n", long_bits + 1);
  time(&mytime);
  printf("ciao Pino\r\n");
  printf("Sono le %s\r\n", ctime(&mytime));
  exit(0);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    0x2e72(%rip),%rax
mov    (%rax),%eax
add    $0x2,%eax
cltq
mov    %rax,-0x10(%rbp)
movq   $0x0,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
lea    0xe79(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe85(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe8e(%rip),%rdi
mov    $0x8,%esi
mov    $0x0,%al
call   1050 <printf@plt>
movq   $0x1,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,-0x10(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <highestOneBitPosition@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x18(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
cmp    -0x10(%rbp),%rax
ja     11bb <main+0x6b>
mov    -0x1c(%rbp),%esi
add    $0x1,%esi
lea    0xe5b(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1060 <time@plt>
lea    0xe5e(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x20(%rbp),%rdi
call   1040 <ctime@plt>
mov    %rax,%rsi
lea    0xe50(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <exit@plt>

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x10,%rsp
mov    0x2e6c(%rip),%rax
movslq (%rax),%rbx
add    $0x2,%rbx
lea    0xee0(%rip),%rdi
call   1030 <puts@plt>
lea    0xe7a(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xe80(%rip),%rdi
mov    $0x8,%esi
xor    %eax,%eax
call   1060 <printf@plt>
mov    $0x1,%ebx
nopl   0x0(%rax,%rax,1)
mov    %rbx,%rdi
call   1040 <highestOneBitPosition@plt>
lea    (%rbx,%rbx,1),%rcx
cmp    %rbx,%rcx
mov    %rcx,%rbx
ja     11b0 <main+0x50>
add    $0x1,%eax
lea    0xe65(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1060 <printf@plt>
lea    0xc(%rsp),%rbx
mov    %rbx,%rdi
call   1070 <time@plt>
lea    0xe8c(%rip),%rdi
call   1030 <puts@plt>
mov    %rbx,%rdi
call   1050 <ctime@plt>
lea    0xe4e(%rip),%rdi
mov    %rax,%rsi
xor    %eax,%eax
call   1060 <printf@plt>
xor    %edi,%edi
call   1080 <exit@plt>

LLVM IR (-O0):
@ULONG_MAX = global i32 0
@.str = [30 x i8] c"Test of unsigned long size:\0D\0A\00"
@.str.1 = [23 x i8] c"\0AC compiler max: %ld\0D\0A\00"
@.str.2 = [28 x i8] c"\0ASizeof unsigned long: %d\0D\0A\00"
@.str.3 = [26 x i8] c"\0AExtimated size: %d bit\0D\0A\00"
@.str.4 = [12 x i8] c"ciao Pino\0D\0A\00"
@.str.5 = [13 x i8] c"Sono le %s\0D\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca i64
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
%6 = load i32, i32* @ULONG_MAX
%7 = add nsw i32 %6, 2
%8 = sext i32 %7 to i64
store i64 %8, i64* %2
store i64 0, i64* %3
store i32 0, i32* %4
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str, i64 0, i64 0))
%10 = load i64, i64* %2
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %10)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i64 8)
store i64 1, i64* %3
br label %13
13: ; preds = %19, %0
%14 = load i64, i64* %3
store i64 %14, i64* %2
%15 = load i64, i64* %3
%16 = call i32 @highestOneBitPosition(i64 %15)
store i32 %16, i32* %4
%17 = load i64, i64* %3
%18 = mul i64 %17, 2
store i64 %18, i64* %3
br label %19
19: ; preds = %13
%20 = load i64, i64* %3
%21 = load i64, i64* %2
%22 = icmp ugt i64 %20, %21
br i1 %22, label %13, label %23
23: ; preds = %19
%24 = load i32, i32* %4
%25 = add nsw i32 %24, 1
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = call i32 @time(i32* %5)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.4, i64 0, i64 0))
%29 = call i8* @ctime(i32* %5)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %29)
%31 = call i32 @exit(i32 0)
unreachable
}

LLVM IR (-O2):
@ULONG_MAX = global i32 0
@.str.1 = [23 x i8] c"\0AC compiler max: %ld\0D\0A\00"
@.str.2 = [28 x i8] c"\0ASizeof unsigned long: %d\0D\0A\00"
@.str.3 = [26 x i8] c"\0AExtimated size: %d bit\0D\0A\00"
@.str.5 = [13 x i8] c"Sono le %s\0D\0A\00"
@str = [29 x i8] c"Test of unsigned long size:\0D\00"
@str.6 = [11 x i8] c"ciao Pino\0D\00"
define i32 @main() {
%1 = alloca i32
%2 = load i32, i32* @ULONG_MAX
%3 = add nsw i32 %2, 2
%4 = sext i32 %3 to i64
%5 = bitcast i32* %1 to i8*
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @str, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.1, i64 0, i64 0), i64 %4)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i64 8)
br label %9
9: ; preds = %9, %0
%10 = phi i64 [ 1, %0 ], [ %12, %9 ]
%11 = tail call i32 @highestOneBitPosition(i64 %10)
%12 = shl i64 %10, 1
%13 = icmp ugt i64 %12, %10
br i1 %13, label %9, label %14
14: ; preds = %9
%15 = add nsw i32 %11, 1
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @.str.3, i64 0, i64 0), i32 %15)
%17 = call i32 @time(i32* %1)
%18 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @str.6, i64 0, i64 0))
%19 = call i8* @ctime(i32* %1)
%20 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i8* %19)
%21 = call i32 @exit(i32 0)
unreachable
}