#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 *, int *);
void priklad_jedna() {
  printf("========== PRIKLAD 1 ==========\n");
  int a, b, *p_a, *p_b;
  p_a = &a;
  p_b = &b;
  printf("Zadejte promennou A: ");
  scanf("%d", p_a);
  printf("Zadejte promennou B: ");
  scanf("%d", p_b);
  printf("Promenna A. Adresa: %p    Hodnota: %d    Adresa pointeru: %p\n", p_a,
         *p_a, &p_a);
  printf("Promenna B. Adresa: %p    Hodnota: %d    Adresa pointeru: %p\n", p_b,
         *p_b, &p_b);
  printf("Soucet A + B = %d\n", (*p_a + *p_b));
  printf("========== KONEC PRIKLADU 1 ==========\n");
}


x86 assembly (clang, -O0):
<priklad_jedna>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    -0x4(%rbp),%rax
mov    %rax,-0x10(%rbp)
lea    -0x8(%rbp),%rax
mov    %rax,-0x18(%rbp)
lea    0xed4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xed8(%rip),%rdi
call   1040 <scanf@plt>
lea    0xecf(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xeba(%rip),%rdi
call   1040 <scanf@plt>
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    (%rax),%edx
lea    0xebd(%rip),%rdi
lea    -0x10(%rbp),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x18(%rbp),%rsi
mov    -0x18(%rbp),%rax
mov    (%rax),%edx
lea    0xedf(%rip),%rdi
lea    -0x18(%rbp),%rcx
mov    $0x0,%al
call   1030 <printf@plt>
mov    -0x10(%rbp),%rax
mov    (%rax),%esi
mov    -0x18(%rbp),%rax
add    (%rax),%esi
lea    0xeff(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xf04(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<priklad_jedna>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
lea    0xf7e(%rip),%rdi
call   1030 <puts@plt>
lea    0xc(%rsp),%r15
mov    %r15,0x18(%rsp)
lea    0x8(%rsp),%r14
mov    %r14,0x10(%rsp)
lea    0xea0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xea8(%rip),%rbx
mov    %rbx,%rdi
mov    %r15,%rsi
call   1050 <scanf@plt>
lea    0xe99(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r14,%rsi
call   1050 <scanf@plt>
mov    0xc(%rsp),%edx
lea    0xe92(%rip),%rdi
lea    0x18(%rsp),%rcx
mov    %r15,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x8(%rsp),%edx
lea    0xeb6(%rip),%rdi
lea    0x10(%rsp),%rcx
mov    %r14,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x18(%rsp),%rax
mov    0x10(%rsp),%rcx
mov    (%rcx),%esi
add    (%rax),%esi
lea    0xed0(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xef5(%rip),%rdi
call   1030 <puts@plt>
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [33 x i8] c"========== PRIKLAD 1 ==========\0A\00"
@.str.1 = [22 x i8] c"Zadejte promennou A: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [22 x i8] c"Zadejte promennou B: \00"
@.str.4 = [62 x i8] c"Promenna A. Adresa: %p Hodnota: %d Adresa pointeru: %p\0A\00"
@.str.5 = [62 x i8] c"Promenna B. Adresa: %p Hodnota: %d Adresa pointeru: %p\0A\00"
@.str.6 = [19 x i8] c"Soucet A + B = %d\0A\00"
@.str.7 = [40 x i8] c"========== KONEC PRIKLADU 1 ==========\0A\00"
define void @priklad_jedna() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str, i64 0, i64 0))
store i32* %1, i32** %3
store i32* %2, i32** %4
%6 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%7 = load i32*, i32** %3
%8 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %7)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%10 = load i32*, i32** %4
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %10)
%12 = load i32*, i32** %3
%13 = load i32*, i32** %3
%14 = load i32, i32* %13
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), i32* %12, i32 %14, i32** %3)
%16 = load i32*, i32** %4
%17 = load i32*, i32** %4
%18 = load i32, i32* %17
%19 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i32* %16, i32 %18, i32** %4)
%20 = load i32*, i32** %3
%21 = load i32, i32* %20
%22 = load i32*, i32** %4
%23 = load i32, i32* %22
%24 = add nsw i32 %21, %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.7, i64 0, i64 0))
ret void
}

LLVM IR (-O2):
@.str.1 = [22 x i8] c"Zadejte promennou A: \00"
@.str.2 = [3 x i8] c"%d\00"
@.str.3 = [22 x i8] c"Zadejte promennou B: \00"
@.str.4 = [62 x i8] c"Promenna A. Adresa: %p Hodnota: %d Adresa pointeru: %p\0A\00"
@.str.5 = [62 x i8] c"Promenna B. Adresa: %p Hodnota: %d Adresa pointeru: %p\0A\00"
@.str.6 = [19 x i8] c"Soucet A + B = %d\0A\00"
@str = [32 x i8] c"========== PRIKLAD 1 ==========\00"
@str.8 = [39 x i8] c"========== KONEC PRIKLADU 1 ==========\00"
define void @priklad_jedna() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32*
%4 = alloca i32*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([32 x i8], [32 x i8]* @str, i64 0, i64 0))
%6 = bitcast i32* %1 to i8*
%7 = bitcast i32* %2 to i8*
%8 = bitcast i32** %3 to i8*
%9 = bitcast i32** %4 to i8*
store i32* %1, i32** %3
store i32* %2, i32** %4
%10 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %1)
%12 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), i32* %2)
%14 = load i32, i32* %1
%15 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.4, i64 0, i64 0), i32* %1, i32 %14, i32** %3)
%16 = load i32, i32* %2
%17 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([62 x i8], [62 x i8]* @.str.5, i64 0, i64 0), i32* %2, i32 %16, i32** %4)
%18 = load i32*, i32** %3
%19 = load i32, i32* %18
%20 = load i32*, i32** %4
%21 = load i32, i32* %20
%22 = add nsw i32 %21, %19
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.6, i64 0, i64 0), i32 %22)
%24 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([39 x i8], [39 x i8]* @str.8, i64 0, i64 0))
ret void
}