#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 uint64_t;
typedef int uint32_t;

/* Variables and functions */
int EXIT_SUCCESS;
int RAND_MAX;
int UINT_MAX;
int ULLONG_MAX;
int /*<<< orphan*/ printf(char *, ...);
int rand();
int c_plus_example(void) {
  printf("!!!Hello %s!!!\n", "World");
  uint32_t i = UINT_MAX;
  printf("The max unsigned integer number is %u[%x]\n", i, i);
  uint64_t l = ULLONG_MAX;
  printf("The max unsigned long number is %I64u[%I64x]\n", l, l);
  uint64_t l4 = l >> (4 * 8);
  printf("The long shift 4 right number is %I64u[%I64x]\n", l4, l4);
  uint64_t r = rand() * (ULLONG_MAX / RAND_MAX);
  printf("The random long number is %I64u[%I64x]\n", r, r);
  uint32_t rr = r >> (4 * 8);
  printf("The long random number right is %u[%x]\n", rr, rr);
  uint32_t rl = r;
  printf("The long random number left is %u[%x]\n", rl, rl);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<c_plus_example>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
lea    0xeda(%rip),%rsi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e9c(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%esi
mov    -0x4(%rbp),%edx
lea    0xec0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2e84(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%esi
mov    -0x8(%rbp),%edx
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x8(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,-0xc(%rbp)
mov    -0xc(%rbp),%esi
mov    -0xc(%rbp),%edx
lea    0xed8(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    $0x0,%al
call   1040 <rand@plt>
mov    %eax,-0x1c(%rbp)
mov    0x2e39(%rip),%rax
mov    (%rax),%eax
mov    0x2e20(%rip),%rcx
cltd
idivl  (%rcx)
mov    %eax,%ecx
mov    -0x1c(%rbp),%eax
imul   %ecx,%eax
mov    %eax,-0x10(%rbp)
mov    -0x10(%rbp),%esi
mov    -0x10(%rbp),%edx
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    $0x20,%ecx
sar    %cl,%eax
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%esi
mov    -0x14(%rbp),%edx
lea    0xed2(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%eax
mov    %eax,-0x18(%rbp)
mov    -0x18(%rbp),%esi
mov    -0x18(%rbp),%edx
lea    0xee0(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    0x2dac(%rip),%rax
mov    (%rax),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<c_plus_example>:
push   %r14
push   %rbx
push   %rax
lea    0xed5(%rip),%rdi
lea    0xede(%rip),%rsi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2ea0(%rip),%rax
mov    (%rax),%edx
lea    0xecd(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2e8f(%rip),%r14
mov    (%r14),%edx
lea    0xede(%rip),%rdi
mov    %edx,%esi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xefc(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
xor    %eax,%eax
call   1040 <rand@plt>
mov    %eax,%ebx
mov    (%r14),%eax
mov    0x2e4b(%rip),%rcx
cltd
idivl  (%rcx)
imul   %eax,%ebx
lea    0xf04(%rip),%rdi
mov    %ebx,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf1a(%rip),%rdi
xor    %eax,%eax
call   1030 <printf@plt>
lea    0xf34(%rip),%rdi
mov    %ebx,%esi
mov    %ebx,%edx
xor    %eax,%eax
call   1030 <printf@plt>
mov    0x2dfc(%rip),%rax
mov    (%rax),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [16 x i8] c"!!!Hello %s!!!\0A\00"
@.str.1 = [6 x i8] c"World\00"
@UINT_MAX = global i32 0
@.str.2 = [43 x i8] c"The max unsigned integer number is %u[%x]\0A\00"
@ULLONG_MAX = global i32 0
@.str.3 = [46 x i8] c"The max unsigned long number is %I64u[%I64x]\0A\00"
@.str.4 = [47 x i8] c"The long shift 4 right number is %I64u[%I64x]\0A\00"
@RAND_MAX = global i32 0
@.str.5 = [40 x i8] c"The random long number is %I64u[%I64x]\0A\00"
@.str.6 = [40 x i8] c"The long random number right is %u[%x]\0A\00"
@.str.7 = [39 x i8] c"The long random number left is %u[%x]\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @c_plus_example() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%8 = load i32, i32* @UINT_MAX
store i32 %8, i32* %1
%9 = load i32, i32* %1
%10 = load i32, i32* %1
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %9, i32 %10)
%12 = load i32, i32* @ULLONG_MAX
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = load i32, i32* %2
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 %13, i32 %14)
%16 = load i32, i32* %2
%17 = ashr i32 %16, 32
store i32 %17, i32* %3
%18 = load i32, i32* %3
%19 = load i32, i32* %3
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 %18, i32 %19)
%21 = call i32 (...) @rand()
%22 = load i32, i32* @ULLONG_MAX
%23 = load i32, i32* @RAND_MAX
%24 = sdiv i32 %22, %23
%25 = mul nsw i32 %21, %24
store i32 %25, i32* %4
%26 = load i32, i32* %4
%27 = load i32, i32* %4
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i32 %26, i32 %27)
%29 = load i32, i32* %4
%30 = ashr i32 %29, 32
store i32 %30, i32* %5
%31 = load i32, i32* %5
%32 = load i32, i32* %5
%33 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 %31, i32 %32)
%34 = load i32, i32* %4
store i32 %34, i32* %6
%35 = load i32, i32* %6
%36 = load i32, i32* %6
%37 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i32 %35, i32 %36)
%38 = load i32, i32* @EXIT_SUCCESS
ret i32 %38
}

LLVM IR (-O2):
@.str = [16 x i8] c"!!!Hello %s!!!\0A\00"
@.str.1 = [6 x i8] c"World\00"
@UINT_MAX = global i32 0
@.str.2 = [43 x i8] c"The max unsigned integer number is %u[%x]\0A\00"
@ULLONG_MAX = global i32 0
@.str.3 = [46 x i8] c"The max unsigned long number is %I64u[%I64x]\0A\00"
@.str.4 = [47 x i8] c"The long shift 4 right number is %I64u[%I64x]\0A\00"
@RAND_MAX = global i32 0
@.str.5 = [40 x i8] c"The random long number is %I64u[%I64x]\0A\00"
@.str.6 = [40 x i8] c"The long random number right is %u[%x]\0A\00"
@.str.7 = [39 x i8] c"The long random number left is %u[%x]\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @c_plus_example() {
%1 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0))
%2 = load i32, i32* @UINT_MAX
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([43 x i8], [43 x i8]* @.str.2, i64 0, i64 0), i32 %2, i32 %2)
%4 = load i32, i32* @ULLONG_MAX
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([46 x i8], [46 x i8]* @.str.3, i64 0, i64 0), i32 %4, i32 %4)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([47 x i8], [47 x i8]* @.str.4, i64 0, i64 0), i32 poison, i32 poison)
%7 = tail call i32 (...) @rand()
%8 = load i32, i32* @ULLONG_MAX
%9 = load i32, i32* @RAND_MAX
%10 = sdiv i32 %8, %9
%11 = mul nsw i32 %10, %7
%12 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.5, i64 0, i64 0), i32 %11, i32 %11)
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([40 x i8], [40 x i8]* @.str.6, i64 0, i64 0), i32 poison, i32 poison)
%14 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @.str.7, i64 0, i64 0), i32 %11, i32 %11)
%15 = load i32, i32* @EXIT_SUCCESS
ret i32 %15
}