#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 getMinOverTake(int *, int *, int);
int /*<<< orphan*/ printf(char *, int);
scalar_t__ scanf(char *, int *);
int main(void) {
  int N, startOrder[100], lastOrder[100], i;
  while (scanf("%d", &N) > 0) {
    for (i = 0; i < N; i++) {
      scanf("%d", &startOrder[i]);
      startOrder[i]--;
    }
    for (i = 0; i < N; i++) {
      scanf("%d", &lastOrder[i]);
      lastOrder[i]--;
    }
    printf("%d\n", getMinOverTake(startOrder, lastOrder, N));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x340,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xeb7(%rip),%rdi
lea    -0x8(%rbp),%rsi
call   1050 <scanf@plt>
cmp    $0x0,%rax
jle    1251 <main+0x121>
movl   $0x0,-0x334(%rbp)
mov    -0x334(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11c2 <main+0x92>
movslq -0x334(%rbp),%rax
lea    -0x1a0(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe6f(%rip),%rdi
call   1050 <scanf@plt>
movslq -0x334(%rbp),%rax
mov    -0x1a0(%rbp,%rax,4),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x1a0(%rbp,%rax,4)
mov    -0x334(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x334(%rbp)
jmp    1166 <main+0x36>
movl   $0x0,-0x334(%rbp)
mov    -0x334(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1228 <main+0xf8>
movslq -0x334(%rbp),%rax
lea    -0x330(%rbp),%rsi
shl    $0x2,%rax
add    %rax,%rsi
lea    0xe09(%rip),%rdi
call   1050 <scanf@plt>
movslq -0x334(%rbp),%rax
mov    -0x330(%rbp,%rax,4),%ecx
add    $0xffffffff,%ecx
mov    %ecx,-0x330(%rbp,%rax,4)
mov    -0x334(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x334(%rbp)
jmp    11cc <main+0x9c>
lea    -0x1a0(%rbp),%rdi
lea    -0x330(%rbp),%rsi
mov    -0x8(%rbp),%edx
call   1030 <getMinOverTake@plt>
mov    %eax,%esi
lea    0xdbc(%rip),%rdi
call   1040 <printf@plt>
jmp    1142 <main+0x12>
xor    %eax,%eax
add    $0x340,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x338,%rsp
lea    0xeb8(%rip),%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
test   %rax,%rax
jle    1219 <main+0xe9>
lea    0x1a0(%rsp),%r14
lea    0xe96(%rip),%r13
lea    0x10(%rsp),%r15
lea    0xe8d(%rip),%rbx
jmp    11a7 <main+0x77>
nopl   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %r15,%rsi
call   1030 <getMinOverTake@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %r13,%rdi
lea    0xc(%rsp),%rsi
call   1050 <scanf@plt>
test   %rax,%rax
jle    1219 <main+0xe9>
mov    0xc(%rsp),%edx
test   %edx,%edx
jle    1180 <main+0x50>
mov    %r14,%rbp
xor    %r12d,%r12d
cs nopw 0x0(%rax,%rax,1)
nop
mov    %r13,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
addl   $0xffffffff,0x0(%rbp)
add    $0x1,%r12
movslq 0xc(%rsp),%rdx
add    $0x4,%rbp
cmp    %rdx,%r12
jl     11c0 <main+0x90>
test   %edx,%edx
jle    1180 <main+0x50>
mov    %rbx,%r12
mov    %r15,%rbp
xor    %ebx,%ebx
nopl   (%rax)
mov    %r13,%rdi
mov    %rbp,%rsi
call   1050 <scanf@plt>
addl   $0xffffffff,0x0(%rbp)
add    $0x1,%rbx
movslq 0xc(%rsp),%rdx
add    $0x4,%rbp
cmp    %rdx,%rbx
jl     11f0 <main+0xc0>
mov    %r12,%rbx
jmp    1180 <main+0x50>
xor    %eax,%eax
add    $0x338,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca [100 x i32]
%4 = alloca [100 x i32]
%5 = alloca i32
store i32 0, i32* %1
br label %6
6: ; preds = %45, %0
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %2)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %51
9: ; preds = %6
store i32 0, i32* %5
br label %10
10: ; preds = %24, %9
%11 = load i32, i32* %5
%12 = load i32, i32* %2
%13 = icmp slt i32 %11, %12
br i1 %13, label %14, label %27
14: ; preds = %10
%15 = load i32, i32* %5
%16 = sext i32 %15 to i64
%17 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %16
%18 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %17)
%19 = load i32, i32* %5
%20 = sext i32 %19 to i64
%21 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %20
%22 = load i32, i32* %21
%23 = add nsw i32 %22, -1
store i32 %23, i32* %21
br label %24
24: ; preds = %14
%25 = load i32, i32* %5
%26 = add nsw i32 %25, 1
store i32 %26, i32* %5
br label %10
27: ; preds = %10
store i32 0, i32* %5
br label %28
28: ; preds = %42, %27
%29 = load i32, i32* %5
%30 = load i32, i32* %2
%31 = icmp slt i32 %29, %30
br i1 %31, label %32, label %45
32: ; preds = %28
%33 = load i32, i32* %5
%34 = sext i32 %33 to i64
%35 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %34
%36 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %35)
%37 = load i32, i32* %5
%38 = sext i32 %37 to i64
%39 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 %38
%40 = load i32, i32* %39
%41 = add nsw i32 %40, -1
store i32 %41, i32* %39
br label %42
42: ; preds = %32
%43 = load i32, i32* %5
%44 = add nsw i32 %43, 1
store i32 %44, i32* %5
br label %28
45: ; preds = %28
%46 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
%47 = getelementptr inbounds [100 x i32], [100 x i32]* %4, i64 0, i64 0
%48 = load i32, i32* %2
%49 = call i32 @getMinOverTake(i32* %46, i32* %47, i32 %48)
%50 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %49)
br label %6
51: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%d\00"
@.str.1 = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100 x i32]
%3 = alloca [100 x i32]
%4 = bitcast i32* %1 to i8*
%5 = bitcast [100 x i32]* %2 to i8*
%6 = bitcast [100 x i32]* %3 to i8*
%7 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%8 = icmp sgt i64 %7, 0
br i1 %8, label %9, label %43
9: ; preds = %0
%10 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 0
%11 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 0
br label %12
12: ; preds = %9, %37
%13 = load i32, i32* %1
%14 = icmp sgt i32 %13, 0
br i1 %14, label %17, label %37
15: ; preds = %17
%16 = icmp sgt i32 %24, 0
br i1 %16, label %27, label %37
17: ; preds = %12, %17
%18 = phi i64 [ %23, %17 ], [ 0, %12 ]
%19 = getelementptr inbounds [100 x i32], [100 x i32]* %2, i64 0, i64 %18
%20 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %19)
%21 = load i32, i32* %19
%22 = add nsw i32 %21, -1
store i32 %22, i32* %19
%23 = add nuw nsw i64 %18, 1
%24 = load i32, i32* %1
%25 = sext i32 %24 to i64
%26 = icmp slt i64 %23, %25
br i1 %26, label %17, label %15
27: ; preds = %15, %27
%28 = phi i64 [ %33, %27 ], [ 0, %15 ]
%29 = getelementptr inbounds [100 x i32], [100 x i32]* %3, i64 0, i64 %28
%30 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %29)
%31 = load i32, i32* %29
%32 = add nsw i32 %31, -1
store i32 %32, i32* %29
%33 = add nuw nsw i64 %28, 1
%34 = load i32, i32* %1
%35 = sext i32 %34 to i64
%36 = icmp slt i64 %33, %35
br i1 %36, label %27, label %37
37: ; preds = %27, %12, %15
%38 = phi i32 [ %24, %15 ], [ %13, %12 ], [ %34, %27 ]
%39 = call i32 @getMinOverTake(i32* %10, i32* %11, i32 %38)
%40 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.1, i64 0, i64 0), i32 %39)
%41 = call i64 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i32* %1)
%42 = icmp sgt i64 %41, 0
br i1 %42, label %12, label %43
43: ; preds = %37, %0
ret i32 0
}