#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 */
float pow(float, float);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  float bilangan1, bilangan2;
  float hasil;
  char op;
  char ulang;
  printf("Masukkan bilangan 1 = ");
  scanf("%f", &bilangan1);
awal:
  printf("Masukkan bilangan 2 = ");
  scanf("%f", &bilangan2);
  printf("Masukkan operator = ");
  scanf("%s", &op);
  if (op == '+') {
    hasil = bilangan1 + bilangan2;
    printf("Hasil = %G\n", hasil);
  } else if (op == '-') {
    hasil = bilangan1 - bilangan2;
    printf("Hasil = %G\n", hasil);
  } else if (op == '*') {
    hasil = bilangan1 * bilangan2;
    printf("Hasil = %G\n", hasil);
  } else if (op == '/') {
    hasil = bilangan1 / bilangan2;
    printf("Hasil = %f\n", hasil);
  } else if (op == '^') {
    hasil = pow(bilangan1, bilangan2);
    printf("Hasil = %G\n", hasil);
  } else {
    printf("hasil error\n");
  }
  bilangan1 = hasil;
  printf("\nHitung Ulang[Y/N]");
  scanf("%s", &ulang);
  if (ulang == 'Y' || ulang == 'y') {
    goto awal;
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeba(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xec3(%rip),%rdi
lea    -0x8(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeb4(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xea3(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
lea    0xeab(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xeb2(%rip),%rdi
lea    -0x11(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x11(%rbp),%eax
cmp    $0x2b,%eax
jne    11d7 <main+0xa7>
movss  -0x8(%rbp),%xmm0
addss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe7e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12de <main+0x1ae>
movsbl -0x11(%rbp),%eax
cmp    $0x2d,%eax
jne    120f <main+0xdf>
movss  -0x8(%rbp),%xmm0
subss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe46(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12d9 <main+0x1a9>
movsbl -0x11(%rbp),%eax
cmp    $0x2a,%eax
jne    1247 <main+0x117>
movss  -0x8(%rbp),%xmm0
mulss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xe0e(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12d4 <main+0x1a4>
movsbl -0x11(%rbp),%eax
cmp    $0x2f,%eax
jne    127f <main+0x14f>
movss  -0x8(%rbp),%xmm0
divss  -0xc(%rbp),%xmm0
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xde2(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12cf <main+0x19f>
movsbl -0x11(%rbp),%eax
cmp    $0x5e,%eax
jne    12bc <main+0x18c>
movss  -0x8(%rbp),%xmm0
movss  -0xc(%rbp),%xmm1
call   1050 <pow@plt>
movss  %xmm0,-0x10(%rbp)
movss  -0x10(%rbp),%xmm0
cvtss2sd %xmm0,%xmm0
lea    0xd99(%rip),%rdi
mov    $0x1,%al
call   1030 <printf@plt>
jmp    12ca <main+0x19a>
lea    0xd9e(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
jmp    12cf <main+0x19f>
jmp    12d4 <main+0x1a4>
jmp    12d9 <main+0x1a9>
jmp    12de <main+0x1ae>
movss  -0x10(%rbp),%xmm0
movss  %xmm0,-0x8(%rbp)
lea    0xd7f(%rip),%rdi
mov    $0x0,%al
call   1030 <printf@plt>
lea    0xd49(%rip),%rdi
lea    -0x12(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movsbl -0x12(%rbp),%eax
cmp    $0x59,%eax
je     1322 <main+0x1f2>
movsbl -0x12(%rbp),%eax
cmp    $0x79,%eax
jne    1327 <main+0x1f7>
jmp    115f <main+0x2f>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x18,%rsp
lea    0xec3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xecc(%rip),%rdi
lea    0x10(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
lea    0xed3(%rip),%r13
lea    0xee1(%rip),%rbx
lea    0xf(%rsp),%rbp
lea    0xef0(%rip),%r14
lea    0xe(%rsp),%r15
lea    0xe6b(%rip),%r12
jmp    11e8 <main+0xa8>
lea    0xeee(%rip),%rdi
call   1030 <puts@plt>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
movss  0x8(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
movss  %xmm0,0x10(%rsp)
mov    %r14,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movzbl 0xe(%rsp),%eax
and    $0xdf,%al
cmp    $0x59,%al
jne    12c1 <main+0x181>
lea    0xe43(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe32(%rip),%rdi
lea    0x14(%rsp),%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
mov    %r13,%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbx,%rdi
mov    %rbp,%rsi
xor    %eax,%eax
call   1050 <scanf@plt>
movzbl 0xf(%rsp),%eax
lea    -0x2a(%rax),%ecx
cmp    $0x5,%cl
ja     1250 <main+0x110>
movzbl %cl,%eax
movslq (%r12,%rax,4),%rax
add    %r12,%rax
jmp    *%rax
movss  0x10(%rsp),%xmm0
mulss  0x14(%rsp),%xmm0
jmp    1285 <main+0x145>
nopw   0x0(%rax,%rax,1)
cmp    $0x5e,%al
jne    1197 <main+0x57>
movss  0x10(%rsp),%xmm0
movss  0x14(%rsp),%xmm1
call   1060 <pow@plt>
jmp    1285 <main+0x145>
movss  0x10(%rsp),%xmm0
addss  0x14(%rsp),%xmm0
jmp    1285 <main+0x145>
movss  0x10(%rsp),%xmm0
subss  0x14(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xdcb(%rip),%rdi
jmp    12b5 <main+0x175>
movss  0x10(%rsp),%xmm0
divss  0x14(%rsp),%xmm0
movss  %xmm0,0x8(%rsp)
cvtss2sd %xmm0,%xmm0
lea    0xdb8(%rip),%rdi
mov    $0x1,%al
call   1040 <printf@plt>
jmp    11b0 <main+0x70>
xor    %eax,%eax
add    $0x18,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [23 x i8] c"Masukkan bilangan 1 = \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [23 x i8] c"Masukkan bilangan 2 = \00"
@.str.3 = [21 x i8] c"Masukkan operator = \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [12 x i8] c"Hasil = %G\0A\00"
@.str.6 = [12 x i8] c"Hasil = %f\0A\00"
@.str.7 = [13 x i8] c"hasil error\0A\00"
@.str.8 = [19 x i8] c"\0AHitung Ulang[Y/N]\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca float
%3 = alloca float
%4 = alloca float
%5 = alloca i8
%6 = alloca i8
store i32 0, i32* %1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
br label %9
9: ; preds = %85, %0
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%11 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %3)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %5)
%14 = load i8, i8* %5
%15 = sext i8 %14 to i32
%16 = icmp eq i32 %15, 43
br i1 %16, label %17, label %24
17: ; preds = %9
%18 = load float, float* %2
%19 = load float, float* %3
%20 = fadd float %18, %19
store float %20, float* %4
%21 = load float, float* %4
%22 = fpext float %21 to double
%23 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %22)
br label %74
24: ; preds = %9
%25 = load i8, i8* %5
%26 = sext i8 %25 to i32
%27 = icmp eq i32 %26, 45
br i1 %27, label %28, label %35
28: ; preds = %24
%29 = load float, float* %2
%30 = load float, float* %3
%31 = fsub float %29, %30
store float %31, float* %4
%32 = load float, float* %4
%33 = fpext float %32 to double
%34 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %33)
br label %73
35: ; preds = %24
%36 = load i8, i8* %5
%37 = sext i8 %36 to i32
%38 = icmp eq i32 %37, 42
br i1 %38, label %39, label %46
39: ; preds = %35
%40 = load float, float* %2
%41 = load float, float* %3
%42 = fmul float %40, %41
store float %42, float* %4
%43 = load float, float* %4
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %44)
br label %72
46: ; preds = %35
%47 = load i8, i8* %5
%48 = sext i8 %47 to i32
%49 = icmp eq i32 %48, 47
br i1 %49, label %50, label %57
50: ; preds = %46
%51 = load float, float* %2
%52 = load float, float* %3
%53 = fdiv float %51, %52
store float %53, float* %4
%54 = load float, float* %4
%55 = fpext float %54 to double
%56 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), double %55)
br label %71
57: ; preds = %46
%58 = load i8, i8* %5
%59 = sext i8 %58 to i32
%60 = icmp eq i32 %59, 94
br i1 %60, label %61, label %68
61: ; preds = %57
%62 = load float, float* %2
%63 = load float, float* %3
%64 = call float @pow(float %62, float %63)
store float %64, float* %4
%65 = load float, float* %4
%66 = fpext float %65 to double
%67 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %66)
br label %70
68: ; preds = %57
%69 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.7, i64 0, i64 0))
br label %70
70: ; preds = %68, %61
br label %71
71: ; preds = %70, %50
br label %72
72: ; preds = %71, %39
br label %73
73: ; preds = %72, %28
br label %74
74: ; preds = %73, %17
%75 = load float, float* %4
store float %75, float* %2
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%77 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %6)
%78 = load i8, i8* %6
%79 = sext i8 %78 to i32
%80 = icmp eq i32 %79, 89
br i1 %80, label %85, label %81
81: ; preds = %74
%82 = load i8, i8* %6
%83 = sext i8 %82 to i32
%84 = icmp eq i32 %83, 121
br i1 %84, label %85, label %86
85: ; preds = %81, %74
br label %9
86: ; preds = %81
ret i32 0
}

LLVM IR (-O2):
@.str = [23 x i8] c"Masukkan bilangan 1 = \00"
@.str.1 = [3 x i8] c"%f\00"
@.str.2 = [23 x i8] c"Masukkan bilangan 2 = \00"
@.str.3 = [21 x i8] c"Masukkan operator = \00"
@.str.4 = [3 x i8] c"%s\00"
@.str.5 = [12 x i8] c"Hasil = %G\0A\00"
@.str.6 = [12 x i8] c"Hasil = %f\0A\00"
@.str.8 = [19 x i8] c"\0AHitung Ulang[Y/N]\00"
@str = [12 x i8] c"hasil error\00"
define i32 @main() {
%1 = alloca float
%2 = alloca float
%3 = alloca i8
%4 = alloca i8
%5 = bitcast float* %1 to i8*
%6 = bitcast float* %2 to i8*
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str, i64 0, i64 0))
%8 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %1)
br label %9
9: ; preds = %48, %0
%10 = phi float [ undef, %0 ], [ %49, %48 ]
%11 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), float* %2)
%13 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%14 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %3)
%15 = load i8, i8* %3
switch i8 %15, label %46 [
i8 43, label %16
i8 45, label %22
i8 42, label %28
i8 47, label %34
i8 94, label %40
]
16: ; preds = %9
%17 = load float, float* %1
%18 = load float, float* %2
%19 = fadd float %17, %18
%20 = fpext float %19 to double
%21 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %20)
br label %48
22: ; preds = %9
%23 = load float, float* %1
%24 = load float, float* %2
%25 = fsub float %23, %24
%26 = fpext float %25 to double
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %26)
br label %48
28: ; preds = %9
%29 = load float, float* %1
%30 = load float, float* %2
%31 = fmul float %29, %30
%32 = fpext float %31 to double
%33 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %32)
br label %48
34: ; preds = %9
%35 = load float, float* %1
%36 = load float, float* %2
%37 = fdiv float %35, %36
%38 = fpext float %37 to double
%39 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.6, i64 0, i64 0), double %38)
br label %48
40: ; preds = %9
%41 = load float, float* %1
%42 = load float, float* %2
%43 = call float @pow(float %41, float %42)
%44 = fpext float %43 to double
%45 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.5, i64 0, i64 0), double %44)
br label %48
46: ; preds = %9
%47 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @str, i64 0, i64 0))
br label %48
48: ; preds = %22, %34, %46, %40, %28, %16
%49 = phi float [ %19, %16 ], [ %25, %22 ], [ %31, %28 ], [ %37, %34 ], [ %43, %40 ], [ %10, %46 ]
store float %49, float* %1
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([19 x i8], [19 x i8]* @.str.8, i64 0, i64 0))
%51 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.4, i64 0, i64 0), i8* %4)
%52 = load i8, i8* %4
%53 = and i8 %52, -33
%54 = icmp eq i8 %53, 89
br i1 %54, label %9, label %55
55: ; preds = %48
ret i32 0
}