#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*/ getchar();
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ putchar(char);
int /*<<< orphan*/ puts(char *);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  char nama[10], nim[10];
  int ap1, ap2;
  float ap;
  putchar('T');
  putchar('.');
  putchar('I');
  putchar('n');
  putchar('f');
  putchar('o');
  putchar('r');
  putchar('m');
  putchar('a');
  putchar('t');
  putchar('i');
  putchar('k');
  putchar('a');
  getchar();
  printf("masukkan nama anda: ");
  scanf("%s", &nama);
  printf("masukkan NIM anda : ");
  scanf("%s", &nim);
  printf("masukkan nilai AP1 : ");
  scanf("%d", ap1);
  printf("masukkan nilai AP2 : ");
  scanf("%d", ap2);
  ap = (float)ap1 + ap2 / 2;
  getchar();
  printf("Nama : %s\n", nama);
  printf("NIM : %s\n", nim);
  printf("Rata-rata nilai AP : %.2f\n", ap);
  puts("Tetap semangat belajar AP :)");
  getchar();
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x54,%edi
call   1030 <putchar@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    $0x49,%edi
call   1030 <putchar@plt>
mov    $0x6e,%edi
call   1030 <putchar@plt>
mov    $0x66,%edi
call   1030 <putchar@plt>
mov    $0x6f,%edi
call   1030 <putchar@plt>
mov    $0x72,%edi
call   1030 <putchar@plt>
mov    $0x6d,%edi
call   1030 <putchar@plt>
mov    $0x61,%edi
call   1030 <putchar@plt>
mov    $0x74,%edi
call   1030 <putchar@plt>
mov    $0x69,%edi
call   1030 <putchar@plt>
mov    $0x6b,%edi
call   1030 <putchar@plt>
mov    $0x61,%edi
call   1030 <putchar@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
lea    0xe11(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xe18(%rip),%rdi
lea    -0xe(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xe09(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    0xdf8(%rip),%rdi
lea    -0x18(%rbp),%rsi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xdfe(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x1c(%rbp),%esi
lea    0xe03(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
lea    0xdf8(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
mov    -0x20(%rbp),%esi
lea    0xde4(%rip),%rdi
mov    $0x0,%al
call   1070 <scanf@plt>
cvtsi2ssl -0x1c(%rbp),%xmm0
mov    -0x20(%rbp),%eax
mov    $0x2,%ecx
cltd
idiv   %ecx
cvtsi2ss %eax,%xmm1
addss  %xmm1,%xmm0
movss  %xmm0,-0x24(%rbp)
mov    $0x0,%al
call   1060 <getchar@plt>
lea    -0xe(%rbp),%rsi
lea    0xdc7(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
lea    -0x18(%rbp),%rsi
lea    0xdc0(%rip),%rdi
mov    $0x0,%al
call   1050 <printf@plt>
movss  -0x24(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xdb3(%rip),%rdi
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xdc0(%rip),%rdi
call   1040 <puts@plt>
mov    $0x0,%al
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x20,%rsp
mov    $0x54,%edi
call   1030 <putchar@plt>
mov    $0x2e,%edi
call   1030 <putchar@plt>
mov    $0x49,%edi
call   1030 <putchar@plt>
mov    $0x6e,%edi
call   1030 <putchar@plt>
mov    $0x66,%edi
call   1030 <putchar@plt>
mov    $0x6f,%edi
call   1030 <putchar@plt>
mov    $0x72,%edi
call   1030 <putchar@plt>
mov    $0x6d,%edi
call   1030 <putchar@plt>
mov    $0x61,%edi
call   1030 <putchar@plt>
mov    $0x74,%edi
call   1030 <putchar@plt>
mov    $0x69,%edi
call   1030 <putchar@plt>
mov    $0x6b,%edi
call   1030 <putchar@plt>
mov    $0x61,%edi
call   1030 <putchar@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xe17(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe1e(%rip),%rbx
lea    0x16(%rsp),%r14
mov    %rbx,%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xe08(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xc(%rsp),%r15
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xdfd(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe05(%rip),%rbx
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
lea    0xdf7(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
mov    %rbx,%rdi
xor    %eax,%eax
call   1070 <scanf@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
lea    0xdee(%rip),%rdi
mov    %r14,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xde8(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xde1(%rip),%rdi
xorps  %xmm0,%xmm0
mov    $0x1,%al
call   1050 <printf@plt>
lea    0xdeb(%rip),%rdi
call   1040 <puts@plt>
xor    %eax,%eax
call   1060 <getchar@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [21 x i8] c"masukkan nama anda: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [21 x i8] c"masukkan NIM anda : \00"
@.str.3 = [22 x i8] c"masukkan nilai AP1 : \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [22 x i8] c"masukkan nilai AP2 : \00"
@.str.6 = [11 x i8] c"Nama : %s\0A\00"
@.str.7 = [10 x i8] c"NIM : %s\0A\00"
@.str.8 = [27 x i8] c"Rata-rata nilai AP : %.2f\0A\00"
@.str.9 = [29 x i8] c"Tetap semangat belajar AP :)\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [10 x i8]
%3 = alloca [10 x i8]
%4 = alloca i32
%5 = alloca i32
%6 = alloca float
store i32 0, i32* %1
%7 = call i32 @putchar(i8 signext 84)
%8 = call i32 @putchar(i8 signext 46)
%9 = call i32 @putchar(i8 signext 73)
%10 = call i32 @putchar(i8 signext 110)
%11 = call i32 @putchar(i8 signext 102)
%12 = call i32 @putchar(i8 signext 111)
%13 = call i32 @putchar(i8 signext 114)
%14 = call i32 @putchar(i8 signext 109)
%15 = call i32 @putchar(i8 signext 97)
%16 = call i32 @putchar(i8 signext 116)
%17 = call i32 @putchar(i8 signext 105)
%18 = call i32 @putchar(i8 signext 107)
%19 = call i32 @putchar(i8 signext 97)
%20 = call i32 (...) @getchar()
%21 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), [10 x i8]* %2)
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), [10 x i8]* %3)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* %4
%27 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %26)
%28 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%29 = load i32, i32* %5
%30 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 %29)
%31 = load i32, i32* %4
%32 = sitofp i32 %31 to float
%33 = load i32, i32* %5
%34 = sdiv i32 %33, 2
%35 = sitofp i32 %34 to float
%36 = fadd float %32, %35
store float %36, float* %6
%37 = call i32 (...) @getchar()
%38 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%39 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %38)
%40 = getelementptr inbounds [10 x i8], [10 x i8]* %3, i64 0, i64 0
%41 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %40)
%42 = load float, float* %6
%43 = fpext float %42 to double
%44 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), double %43)
%45 = call i32 @puts(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%46 = call i32 (...) @getchar()
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"masukkan nama anda: \00"
@.str.1 = [3 x i8] c"%s\00"
@.str.2 = [21 x i8] c"masukkan NIM anda : \00"
@.str.3 = [22 x i8] c"masukkan nilai AP1 : \00"
@.str.4 = [3 x i8] c"%d\00"
@.str.5 = [22 x i8] c"masukkan nilai AP2 : \00"
@.str.6 = [11 x i8] c"Nama : %s\0A\00"
@.str.7 = [10 x i8] c"NIM : %s\0A\00"
@.str.8 = [27 x i8] c"Rata-rata nilai AP : %.2f\0A\00"
@.str.9 = [29 x i8] c"Tetap semangat belajar AP :)\00"
define i32 @main() {
%1 = alloca [10 x i8]
%2 = alloca [10 x i8]
%3 = getelementptr inbounds [10 x i8], [10 x i8]* %1, i64 0, i64 0
%4 = getelementptr inbounds [10 x i8], [10 x i8]* %2, i64 0, i64 0
%5 = tail call i32 @putchar(i8 signext 84)
%6 = tail call i32 @putchar(i8 signext 46)
%7 = tail call i32 @putchar(i8 signext 73)
%8 = tail call i32 @putchar(i8 signext 110)
%9 = tail call i32 @putchar(i8 signext 102)
%10 = tail call i32 @putchar(i8 signext 111)
%11 = tail call i32 @putchar(i8 signext 114)
%12 = tail call i32 @putchar(i8 signext 109)
%13 = tail call i32 @putchar(i8 signext 97)
%14 = tail call i32 @putchar(i8 signext 116)
%15 = tail call i32 @putchar(i8 signext 105)
%16 = tail call i32 @putchar(i8 signext 107)
%17 = tail call i32 @putchar(i8 signext 97)
%18 = tail call i32 (...) @getchar()
%19 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0))
%20 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), [10 x i8]* %1)
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.2, i64 0, i64 0))
%22 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), [10 x i8]* %2)
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.3, i64 0, i64 0))
%24 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 undef)
%25 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([22 x i8], [22 x i8]* @.str.5, i64 0, i64 0))
%26 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i32 undef)
%27 = call i32 (...) @getchar()
%28 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([11 x i8], [11 x i8]* @.str.6, i64 0, i64 0), i8* %3)
%29 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([10 x i8], [10 x i8]* @.str.7, i64 0, i64 0), i8* %4)
%30 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.8, i64 0, i64 0), double 0.000000e+00)
%31 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.9, i64 0, i64 0))
%32 = call i32 (...) @getchar()
ret i32 0
}