#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 findMaxPrimeSubstr(char *, int *);
int /*<<< orphan*/ gets(char *);
int /*<<< orphan*/ preparePrimeSieve(int *, int);
int /*<<< orphan*/ printf(char *, int);
int main(void) {
  int primeSieve[100000 + 1];
  char strNum[300 + 1];
  preparePrimeSieve(primeSieve, 100000);
  while (1) {
    gets(strNum);
    if (strNum[0] == '0' && strNum[1] == '\0')
      break;
    printf("%d\n", findMaxPrimeSubstr(strNum, primeSieve));
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x61bc0,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x61a90(%rbp),%rdi
mov    $0x186a0,%esi
call   1060 <preparePrimeSieve@plt>
lea    -0x61bc0(%rbp),%rdi
call   1050 <gets@plt>
movsbl -0x61bc0(%rbp),%eax
cmp    $0x30,%eax
jne    1194 <main+0x54>
movsbl -0x61bbf(%rbp),%eax
cmp    $0x0,%eax
jne    1194 <main+0x54>
jmp    11ba <main+0x7a>
lea    -0x61bc0(%rbp),%rdi
lea    -0x61a90(%rbp),%rsi
call   1040 <findMaxPrimeSubstr@plt>
mov    %eax,%esi
lea    0xe50(%rip),%rdi
call   1030 <printf@plt>
jmp    1163 <main+0x23>
xor    %eax,%eax
add    $0x61bc0,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x61bc0,%rsp
lea    0x130(%rsp),%rdi
mov    $0x186a0,%esi
call   1060 <preparePrimeSieve@plt>
mov    %rsp,%rdi
call   1050 <gets@plt>
cmpb   $0x30,(%rsp)
jne    1173 <main+0x33>
cmpb   $0x0,0x1(%rsp)
je     11ba <main+0x7a>
mov    %rsp,%rbx
lea    0x130(%rsp),%r14
lea    0xe7b(%rip),%r15
cs nopw 0x0(%rax,%rax,1)
nop
mov    %rbx,%rdi
mov    %r14,%rsi
call   1040 <findMaxPrimeSubstr@plt>
mov    %r15,%rdi
mov    %eax,%esi
call   1030 <printf@plt>
mov    %rbx,%rdi
call   1050 <gets@plt>
cmpb   $0x30,(%rsp)
jne    1190 <main+0x50>
cmpb   $0x0,0x1(%rsp)
jne    1190 <main+0x50>
xor    %eax,%eax
add    $0x61bc0,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [100001 x i32]
%3 = alloca [301 x i8]
store i32 0, i32* %1
%4 = getelementptr inbounds [100001 x i32], [100001 x i32]* %2, i64 0, i64 0
%5 = call i32 @preparePrimeSieve(i32* %4, i32 100000)
br label %6
6: ; preds = %0, %19
%7 = getelementptr inbounds [301 x i8], [301 x i8]* %3, i64 0, i64 0
%8 = call i32 @gets(i8* %7)
%9 = getelementptr inbounds [301 x i8], [301 x i8]* %3, i64 0, i64 0
%10 = load i8, i8* %9
%11 = sext i8 %10 to i32
%12 = icmp eq i32 %11, 48
br i1 %12, label %13, label %19
13: ; preds = %6
%14 = getelementptr inbounds [301 x i8], [301 x i8]* %3, i64 0, i64 1
%15 = load i8, i8* %14
%16 = sext i8 %15 to i32
%17 = icmp eq i32 %16, 0
br i1 %17, label %18, label %19
18: ; preds = %13
br label %24
19: ; preds = %13, %6
%20 = getelementptr inbounds [301 x i8], [301 x i8]* %3, i64 0, i64 0
%21 = getelementptr inbounds [100001 x i32], [100001 x i32]* %2, i64 0, i64 0
%22 = call i32 @findMaxPrimeSubstr(i8* %20, i32* %21)
%23 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %22)
br label %6
24: ; preds = %18
ret i32 0
}

LLVM IR (-O2):
@.str = [4 x i8] c"%d\0A\00"
define i32 @main() {
%1 = alloca [100001 x i32]
%2 = alloca [301 x i8]
%3 = bitcast [100001 x i32]* %1 to i8*
%4 = getelementptr inbounds [301 x i8], [301 x i8]* %2, i64 0, i64 0
%5 = getelementptr inbounds [100001 x i32], [100001 x i32]* %1, i64 0, i64 0
%6 = call i32 @preparePrimeSieve(i32* %5, i32 100000)
%7 = call i32 @gets(i8* %4)
%8 = load i8, i8* %4
%9 = icmp eq i8 %8, 48
%10 = getelementptr inbounds [301 x i8], [301 x i8]* %2, i64 0, i64 1
%11 = load i8, i8* %10
%12 = icmp eq i8 %11, 0
%13 = select i1 %9, i1 %12, i1 false
br i1 %13, label %23, label %14
14: ; preds = %0, %14
%15 = call i32 @findMaxPrimeSubstr(i8* %4, i32* %5)
%16 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = call i32 @gets(i8* %4)
%18 = load i8, i8* %4
%19 = icmp eq i8 %18, 48
%20 = load i8, i8* %10
%21 = icmp eq i8 %20, 0
%22 = select i1 %19, i1 %21, i1 false
br i1 %22, label %23, label %14
23: ; preds = %14, %0
ret i32 0
}