#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, double);
int round(double);
int /*<<< orphan*/ scanf(char *, ...);
int main() {
  int i, N, br = 0;
  double kune = 100.00, euri = 0.00;
  double k, p;
  double kmin = 0, pmax = 0;
  char imaKune = 'd', imaEure = 'n';
  scanf(" %d", &N);
  for (i = 1; i <= N; i++) {
    scanf(" %lf %lf", &k, &p);
    if (k < kmin) {
      kmin = k;
    }
    if (p > pmax) {
      pmax = p;
    }
    if (imaKune == 'd') {
      if (kmin == 0) {
        kmin = k;
      }
      if (k <= kmin) {
        euri = round((kune / k) * 100) / 100;
        kune = 0.00;
        imaKune = 'n';
        imaEure = 'd';
        br++;
      } else {
        continue;
      }
    } else if (imaEure == 'd') {
      if (p >= pmax) {
        kune = round((euri * p) * 100) / 100;
        euri = 0.00;
        imaKune = 'd';
        imaEure = 'n';
        br++;
      } else {
        continue;
      }
    }
  }
  if (imaKune == 'd') {
    printf("Nakon %d promjena, ostaje mu %.2lf kn.", br, kune);
  } else {
    printf("Nakon %d promjena, ostaje mu %.2lf EUR.", br, euri);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x10(%rbp)
movsd  0xeb2(%rip),%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x38(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x40(%rbp)
movb   $0x64,-0x41(%rbp)
movb   $0x6e,-0x42(%rbp)
lea    0xe8e(%rip),%rdi
lea    -0xc(%rbp),%rsi
mov    $0x0,%al
call   1040 <scanf@plt>
movl   $0x1,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jg     1306 <main+0x1d6>
lea    0xe6d(%rip),%rdi
lea    -0x28(%rbp),%rsi
lea    -0x30(%rbp),%rdx
mov    $0x0,%al
call   1040 <scanf@plt>
movsd  -0x28(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jbe    11cc <main+0x9c>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x30(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jbe    11e6 <main+0xb6>
movsd  -0x30(%rbp),%xmm0
movsd  %xmm0,-0x40(%rbp)
movsbl -0x41(%rbp),%eax
cmp    $0x64,%eax
jne    127d <main+0x14d>
movsd  -0x38(%rbp),%xmm0
xorps  %xmm1,%xmm1
ucomisd %xmm1,%xmm0
jne    1215 <main+0xe5>
jp     1215 <main+0xe5>
movsd  -0x28(%rbp),%xmm0
movsd  %xmm0,-0x38(%rbp)
movsd  -0x28(%rbp),%xmm1
movsd  -0x38(%rbp),%xmm0
ucomisd %xmm1,%xmm0
jb     1273 <main+0x143>
movsd  -0x18(%rbp),%xmm0
divsd  -0x28(%rbp),%xmm0
movsd  0xdc5(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1050 <round@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x20(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x18(%rbp)
movb   $0x6e,-0x41(%rbp)
movb   $0x64,-0x42(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1278 <main+0x148>
jmp    12f8 <main+0x1c8>
jmp    12f3 <main+0x1c3>
movsbl -0x42(%rbp),%eax
cmp    $0x64,%eax
jne    12ee <main+0x1be>
movsd  -0x30(%rbp),%xmm0
ucomisd -0x40(%rbp),%xmm0
jb     12e4 <main+0x1b4>
movsd  -0x20(%rbp),%xmm0
mulsd  -0x30(%rbp),%xmm0
movsd  0xd54(%rip),%xmm1
mulsd  %xmm1,%xmm0
call   1050 <round@plt>
mov    $0x64,%ecx
cltd
idiv   %ecx
cvtsi2sd %eax,%xmm0
movsd  %xmm0,-0x18(%rbp)
xorps  %xmm0,%xmm0
movsd  %xmm0,-0x20(%rbp)
movb   $0x64,-0x41(%rbp)
movb   $0x6e,-0x42(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    12e9 <main+0x1b9>
jmp    12f8 <main+0x1c8>
jmp    12ee <main+0x1be>
jmp    12f3 <main+0x1c3>
jmp    12f8 <main+0x1c8>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    118c <main+0x5c>
movsbl -0x41(%rbp),%eax
cmp    $0x64,%eax
jne    132c <main+0x1fc>
mov    -0x10(%rbp),%esi
movsd  -0x18(%rbp),%xmm0
lea    0xcf3(%rip),%rdi
call   1030 <printf@plt>
jmp    1340 <main+0x210>
mov    -0x10(%rbp),%esi
movsd  -0x20(%rbp),%xmm0
lea    0xd01(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x48,%rsp
lea    0xecb(%rip),%rdi
xor    %r13d,%r13d
lea    0xc(%rsp),%rsi
xor    %eax,%eax
call   1040 <scanf@plt>
cmpl   $0x0,0xc(%rsp)
jle    131b <main+0x1eb>
movsd  0xe99(%rip),%xmm0
mov    $0x64,%r14b
mov    $0x6e,%bl
lea    0x40(%rsp),%r15
lea    0x38(%rsp),%r12
xor    %ebp,%ebp
xorpd  %xmm3,%xmm3
xorpd  %xmm4,%xmm4
xorpd  %xmm1,%xmm1
movsd  %xmm1,0x10(%rsp)
movsd  %xmm0,0x18(%rsp)
xor    %r13d,%r13d
jmp    11ad <main+0x7d>
cs nopw 0x0(%rax,%rax,1)
nop
add    $0x1,%ebp
cmp    0xc(%rsp),%ebp
jge    130d <main+0x1dd>
movsd  %xmm4,0x20(%rsp)
movsd  %xmm3,(%rsp)
lea    0xe55(%rip),%rdi
mov    %r15,%rsi
mov    %r12,%rdx
xor    %eax,%eax
call   1040 <scanf@plt>
movsd  0x40(%rsp),%xmm5
movapd %xmm5,%xmm4
minsd  0x20(%rsp),%xmm4
movsd  0x38(%rsp),%xmm1
movapd %xmm1,%xmm3
maxsd  (%rsp),%xmm3
cmp    $0x64,%r14b
jne    1290 <main+0x160>
movapd %xmm4,%xmm1
cmpeqsd 0xe06(%rip),%xmm1
movapd %xmm1,%xmm2
andpd  %xmm5,%xmm2
andnpd %xmm4,%xmm1
orpd   %xmm2,%xmm1
movapd %xmm1,%xmm4
mov    $0x64,%r14b
ucomisd %xmm5,%xmm1
jb     11a0 <main+0x70>
movsd  0x18(%rsp),%xmm0
divsd  %xmm5,%xmm0
mulsd  0xdcf(%rip),%xmm0
movsd  %xmm3,(%rsp)
movapd %xmm4,0x20(%rsp)
call   1050 <round@plt>
movapd 0x20(%rsp),%xmm4
movsd  (%rsp),%xmm3
cltq
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x10(%rsp)
add    $0x1,%r13d
mov    $0x64,%bl
mov    $0x6e,%r14b
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x18(%rsp)
jmp    11a0 <main+0x70>
nopw   0x0(%rax,%rax,1)
cmp    $0x64,%bl
jne    11a0 <main+0x70>
mov    $0x64,%bl
ucomisd %xmm3,%xmm1
jb     11a0 <main+0x70>
movsd  0x10(%rsp),%xmm0
mulsd  %xmm1,%xmm0
mulsd  0xd49(%rip),%xmm0
movsd  %xmm3,(%rsp)
movapd %xmm4,0x20(%rsp)
call   1050 <round@plt>
movapd 0x20(%rsp),%xmm4
movsd  (%rsp),%xmm3
cltq
imul   $0x51eb851f,%rax,%rax
mov    %rax,%rcx
shr    $0x3f,%rcx
sar    $0x25,%rax
add    %ecx,%eax
xorps  %xmm0,%xmm0
cvtsi2sd %eax,%xmm0
movsd  %xmm0,0x18(%rsp)
add    $0x1,%r13d
mov    $0x6e,%bl
mov    $0x64,%r14b
xorpd  %xmm0,%xmm0
movsd  %xmm0,0x10(%rsp)
jmp    11a0 <main+0x70>
cmp    $0x64,%r14b
jne    132f <main+0x1ff>
movsd  0x18(%rsp),%xmm0
jmp    1323 <main+0x1f3>
movsd  0xcdd(%rip),%xmm0
lea    0xcf3(%rip),%rdi
mov    %r13d,%esi
jmp    133f <main+0x20f>
lea    0xd0e(%rip),%rdi
mov    %r13d,%esi
movsd  0x10(%rsp),%xmm0
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x48,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [4 x i8] c" %d\00"
@.str.1 = [9 x i8] c" %lf %lf\00"
@.str.2 = [39 x i8] c"Nakon %d promjena, ostaje mu %.2lf kn.\00"
@.str.3 = [40 x i8] c"Nakon %d promjena, ostaje mu %.2lf EUR.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca double
%6 = alloca double
%7 = alloca double
%8 = alloca double
%9 = alloca double
%10 = alloca double
%11 = alloca i8
%12 = alloca i8
store i32 0, i32* %1
store i32 0, i32* %4
store double 1.000000e+02, double* %5
store double 0.000000e+00, double* %6
store double 0.000000e+00, double* %9
store double 0.000000e+00, double* %10
store i8 100, i8* %11
store i8 110, i8* %12
%13 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %3)
store i32 1, i32* %2
br label %14
14: ; preds = %78, %0
%15 = load i32, i32* %2
%16 = load i32, i32* %3
%17 = icmp sle i32 %15, %16
br i1 %17, label %18, label %81
18: ; preds = %14
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double* %7, double* %8)
%20 = load double, double* %7
%21 = load double, double* %9
%22 = fcmp olt double %20, %21
br i1 %22, label %23, label %25
23: ; preds = %18
%24 = load double, double* %7
store double %24, double* %9
br label %25
25: ; preds = %23, %18
%26 = load double, double* %8
%27 = load double, double* %10
%28 = fcmp ogt double %26, %27
br i1 %28, label %29, label %31
29: ; preds = %25
%30 = load double, double* %8
store double %30, double* %10
br label %31
31: ; preds = %29, %25
%32 = load i8, i8* %11
%33 = sext i8 %32 to i32
%34 = icmp eq i32 %33, 100
br i1 %34, label %35, label %56
35: ; preds = %31
%36 = load double, double* %9
%37 = fcmp oeq double %36, 0.000000e+00
br i1 %37, label %38, label %40
38: ; preds = %35
%39 = load double, double* %7
store double %39, double* %9
br label %40
40: ; preds = %38, %35
%41 = load double, double* %7
%42 = load double, double* %9
%43 = fcmp ole double %41, %42
br i1 %43, label %44, label %54
44: ; preds = %40
%45 = load double, double* %5
%46 = load double, double* %7
%47 = fdiv double %45, %46
%48 = fmul double %47, 1.000000e+02
%49 = call i32 @round(double %48)
%50 = sdiv i32 %49, 100
%51 = sitofp i32 %50 to double
store double %51, double* %6
store double 0.000000e+00, double* %5
store i8 110, i8* %11
store i8 100, i8* %12
%52 = load i32, i32* %4
%53 = add nsw i32 %52, 1
store i32 %53, i32* %4
br label %55
54: ; preds = %40
br label %78
55: ; preds = %44
br label %77
56: ; preds = %31
%57 = load i8, i8* %12
%58 = sext i8 %57 to i32
%59 = icmp eq i32 %58, 100
br i1 %59, label %60, label %76
60: ; preds = %56
%61 = load double, double* %8
%62 = load double, double* %10
%63 = fcmp oge double %61, %62
br i1 %63, label %64, label %74
64: ; preds = %60
%65 = load double, double* %6
%66 = load double, double* %8
%67 = fmul double %65, %66
%68 = fmul double %67, 1.000000e+02
%69 = call i32 @round(double %68)
%70 = sdiv i32 %69, 100
%71 = sitofp i32 %70 to double
store double %71, double* %5
store double 0.000000e+00, double* %6
store i8 100, i8* %11
store i8 110, i8* %12
%72 = load i32, i32* %4
%73 = add nsw i32 %72, 1
store i32 %73, i32* %4
br label %75
74: ; preds = %60
br label %78
75: ; preds = %64
br label %76
76: ; preds = %75, %56
br label %77
77: ; preds = %76, %55
br label %78
78: ; preds = %77, %74, %54
%79 = load i32, i32* %2
%80 = add nsw i32 %79, 1
store i32 %80, i32* %2
br label %14
81: ; preds = %14
%82 = load i8, i8* %11
%83 = sext i8 %82 to i32
%84 = icmp eq i32 %83, 100
br i1 %84, label %85, label %89
85: ; preds = %81
%86 = load i32, i32* %4
%87 = load double, double* %5
%88 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %86, double %87)
br label %93
89: ; preds = %81
%90 = load i32, i32* %4
%91 = load double, double* %6
%92 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %90, double %91)
br label %93
93: ; preds = %89, %85
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c" %d\00"
@.str.1 = [9 x i8] c" %lf %lf\00"
@.str.2 = [39 x i8] c"Nakon %d promjena, ostaje mu %.2lf kn.\00"
@.str.3 = [40 x i8] c"Nakon %d promjena, ostaje mu %.2lf EUR.\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca double
%3 = alloca double
%4 = bitcast i32* %1 to i8*
%5 = bitcast double* %2 to i8*
%6 = bitcast double* %3 to i8*
%7 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = load i32, i32* %1
%9 = icmp slt i32 %8, 1
br i1 %9, label %61, label %10
10: ; preds = %0, %49
%11 = phi i8 [ %55, %49 ], [ 110, %0 ]
%12 = phi i8 [ %54, %49 ], [ 100, %0 ]
%13 = phi double [ %25, %49 ], [ 0.000000e+00, %0 ]
%14 = phi double [ %53, %49 ], [ 0.000000e+00, %0 ]
%15 = phi double [ %52, %49 ], [ 0.000000e+00, %0 ]
%16 = phi double [ %51, %49 ], [ 1.000000e+02, %0 ]
%17 = phi i32 [ %50, %49 ], [ 0, %0 ]
%18 = phi i32 [ %56, %49 ], [ 1, %0 ]
%19 = call i32 (i8*, ...) @scanf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.1, i64 0, i64 0), double* %2, double* %3)
%20 = load double, double* %2
%21 = fcmp olt double %20, %14
%22 = select i1 %21, double %20, double %14
%23 = load double, double* %3
%24 = fcmp ogt double %23, %13
%25 = select i1 %24, double %23, double %13
%26 = icmp eq i8 %12, 100
br i1 %26, label %27, label %38
27: ; preds = %10
%28 = fcmp oeq double %22, 0.000000e+00
%29 = select i1 %28, double %20, double %22
%30 = fcmp ugt double %20, %29
br i1 %30, label %49, label %31
31: ; preds = %27
%32 = fdiv double %16, %20
%33 = fmul double %32, 1.000000e+02
%34 = call i32 @round(double %33)
%35 = sdiv i32 %34, 100
%36 = sitofp i32 %35 to double
%37 = add nsw i32 %17, 1
br label %49
38: ; preds = %10
%39 = icmp eq i8 %11, 100
br i1 %39, label %40, label %49
40: ; preds = %38
%41 = fcmp ult double %23, %25
br i1 %41, label %49, label %42
42: ; preds = %40
%43 = fmul double %15, %23
%44 = fmul double %43, 1.000000e+02
%45 = call i32 @round(double %44)
%46 = sdiv i32 %45, 100
%47 = sitofp i32 %46 to double
%48 = add nsw i32 %17, 1
br label %49
49: ; preds = %31, %42, %38, %40, %27
%50 = phi i32 [ %37, %31 ], [ %17, %27 ], [ %48, %42 ], [ %17, %40 ], [ %17, %38 ]
%51 = phi double [ 0.000000e+00, %31 ], [ %16, %27 ], [ %47, %42 ], [ %16, %40 ], [ %16, %38 ]
%52 = phi double [ %36, %31 ], [ %15, %27 ], [ 0.000000e+00, %42 ], [ %15, %40 ], [ %15, %38 ]
%53 = phi double [ %29, %31 ], [ %29, %27 ], [ %22, %42 ], [ %22, %40 ], [ %22, %38 ]
%54 = phi i8 [ 110, %31 ], [ 100, %27 ], [ 100, %42 ], [ %12, %40 ], [ %12, %38 ]
%55 = phi i8 [ 100, %31 ], [ %11, %27 ], [ 110, %42 ], [ 100, %40 ], [ %11, %38 ]
%56 = add nuw nsw i32 %18, 1
%57 = load i32, i32* %1
%58 = icmp slt i32 %18, %57
br i1 %58, label %10, label %59
59: ; preds = %49
%60 = icmp eq i8 %54, 100
br i1 %60, label %61, label %65
61: ; preds = %0, %59
%62 = phi double [ %51, %59 ], [ 1.000000e+02, %0 ]
%63 = phi i32 [ %50, %59 ], [ 0, %0 ]
%64 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str.2, i64 0, i64 0), i32 %63, double %62)
br label %67
65: ; preds = %59
%66 = call i32 @printf(i8* getelementptr inbounds ([40 x i8], [40 x i8]* @.str.3, i64 0, i64 0), i32 %50, double %52)
br label %67
67: ; preds = %65, %61
ret i32 0
}