#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 *get_num1();
void *get_num2();
int *get_num3();
int get_num4();
int main() {
  const int *x1 = get_num1();
  x1 = get_num1();
  int *x2_1 = get_num2();
  x2_1 = get_num2();
  (*x2_1)++;
  int *const x2_2 = get_num2();
  (*x2_2)++;
  const int *x3 = get_num3();
  x3 = get_num3();
  int x4 = get_num4();
  return *x1 + *x2_1 + *x2_2 + *x3 + x4;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x0,%al
call   1050 <get_num1@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1050 <get_num1@plt>
mov    %rax,-0x10(%rbp)
mov    $0x0,%al
call   1030 <get_num2@plt>
mov    %rax,-0x18(%rbp)
mov    $0x0,%al
call   1030 <get_num2@plt>
mov    %rax,-0x18(%rbp)
mov    -0x18(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    $0x0,%al
call   1030 <get_num2@plt>
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
mov    (%rax),%ecx
add    $0x1,%ecx
mov    %ecx,(%rax)
mov    $0x0,%al
call   1060 <get_num3@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1060 <get_num3@plt>
mov    %rax,-0x28(%rbp)
mov    $0x0,%al
call   1040 <get_num4@plt>
mov    %eax,-0x2c(%rbp)
mov    -0x10(%rbp),%rax
mov    (%rax),%eax
mov    -0x18(%rbp),%rcx
add    (%rcx),%eax
mov    -0x20(%rbp),%rcx
add    (%rcx),%eax
mov    -0x28(%rbp),%rcx
add    (%rcx),%eax
add    -0x2c(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r12
push   %rbx
push   %rax
xor    %eax,%eax
call   1050 <get_num1@plt>
xor    %eax,%eax
call   1050 <get_num1@plt>
mov    %rax,%r14
xor    %eax,%eax
call   1030 <get_num2@plt>
xor    %eax,%eax
call   1030 <get_num2@plt>
mov    %rax,%r15
addl   $0x1,(%rax)
xor    %eax,%eax
call   1030 <get_num2@plt>
mov    %rax,%rbx
addl   $0x1,(%rax)
xor    %eax,%eax
call   1060 <get_num3@plt>
xor    %eax,%eax
call   1060 <get_num3@plt>
mov    %rax,%r12
xor    %eax,%eax
call   1040 <get_num4@plt>
add    (%r14),%eax
add    (%r15),%eax
add    (%rbx),%eax
add    (%r12),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32*
%3 = alloca i32*
%4 = alloca i32*
%5 = alloca i32*
%6 = alloca i32
store i32 0, i32* %1
%7 = call i32* (...) @get_num1()
store i32* %7, i32** %2
%8 = call i32* (...) @get_num1()
store i32* %8, i32** %2
%9 = call i8* (...) @get_num2()
%10 = bitcast i8* %9 to i32*
store i32* %10, i32** %3
%11 = call i8* (...) @get_num2()
%12 = bitcast i8* %11 to i32*
store i32* %12, i32** %3
%13 = load i32*, i32** %3
%14 = load i32, i32* %13
%15 = add nsw i32 %14, 1
store i32 %15, i32* %13
%16 = call i8* (...) @get_num2()
%17 = bitcast i8* %16 to i32*
store i32* %17, i32** %4
%18 = load i32*, i32** %4
%19 = load i32, i32* %18
%20 = add nsw i32 %19, 1
store i32 %20, i32* %18
%21 = call i32* (...) @get_num3()
store i32* %21, i32** %5
%22 = call i32* (...) @get_num3()
store i32* %22, i32** %5
%23 = call i32 (...) @get_num4()
store i32 %23, i32* %6
%24 = load i32*, i32** %2
%25 = load i32, i32* %24
%26 = load i32*, i32** %3
%27 = load i32, i32* %26
%28 = add nsw i32 %25, %27
%29 = load i32*, i32** %4
%30 = load i32, i32* %29
%31 = add nsw i32 %28, %30
%32 = load i32*, i32** %5
%33 = load i32, i32* %32
%34 = add nsw i32 %31, %33
%35 = load i32, i32* %6
%36 = add nsw i32 %34, %35
ret i32 %36
}

LLVM IR (-O2):
define i32 @main() {
%1 = tail call i32* (...) @get_num1()
%2 = tail call i32* (...) @get_num1()
%3 = tail call i8* (...) @get_num2()
%4 = tail call i8* (...) @get_num2()
%5 = bitcast i8* %4 to i32*
%6 = load i32, i32* %5
%7 = add nsw i32 %6, 1
store i32 %7, i32* %5
%8 = tail call i8* (...) @get_num2()
%9 = bitcast i8* %8 to i32*
%10 = load i32, i32* %9
%11 = add nsw i32 %10, 1
store i32 %11, i32* %9
%12 = tail call i32* (...) @get_num3()
%13 = tail call i32* (...) @get_num3()
%14 = tail call i32 (...) @get_num4()
%15 = load i32, i32* %2
%16 = load i32, i32* %5
%17 = load i32, i32* %9
%18 = load i32, i32* %13
%19 = add i32 %15, %14
%20 = add i32 %19, %16
%21 = add i32 %20, %17
%22 = add i32 %21, %18
ret i32 %22
}