#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 *, unsigned long);
unsigned long strlen(char const *);
int main(int argc, char *argv[]) {
  const char *numbers =
      "731671765313306249192251196744265747423553491949349698352031277450632623"
      "957831801698480186947885184385861560789112949495459501737958331952853208"
      "805511125406987471585238630507156932909632952274430435576689664895044524"
      "452316173185640309871112172238311362229893423380308135336276614282806444"
      "486645238749303589072962904915604407723907138105158593079608667017242712"
      "188399879790879227492190169972088809377665727333001053367881220235421809"
      "751254540594752243525849077116705560136048395864467063244157221553975369"
      "781797784617406495514929086256932197846862248283972241375657056057490261"
      "407972968652414535100474821663704844031998900088952434506585412275886668"
      "811642717147992444292823086346567481391912316282458617866458359124566529"
      "476545682848912883142607690042242190226710556263211111093705442175069416"
      "589604080719840385096245544436298123098787992724428490918884580156166097"
      "919133875499200524063689912560717606058861164671094050775410022569831552"
      "0005593572972571636269561882670428252483600823257530420752963450";
  unsigned long highest = 0;
  unsigned long len = strlen(numbers);
  unsigned long product;
  int i, j;
  for (i = 0; i < len; ++i) {
    product = 1;
    for (j = 0; j < 13; ++j) {
      product *= (numbers[i + j] - '0');
    }
    if (product > highest) {
      highest = product;
    }
  }
  printf("Highest product: %lu\n", highest);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x40,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    0xec3(%rip),%rax
mov    %rax,-0x18(%rbp)
movq   $0x0,-0x20(%rbp)
mov    -0x18(%rbp),%rdi
call   1030 <strlen@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x34(%rbp)
movslq -0x34(%rbp),%rax
cmp    -0x28(%rbp),%rax
jae    11da <main+0xba>
movq   $0x1,-0x30(%rbp)
movl   $0x0,-0x38(%rbp)
cmpl   $0xd,-0x38(%rbp)
jge    11b1 <main+0x91>
mov    -0x18(%rbp),%rax
mov    -0x34(%rbp),%ecx
add    -0x38(%rbp),%ecx
movslq %ecx,%rcx
movsbl (%rax,%rcx,1),%eax
sub    $0x30,%eax
cltq
imul   -0x30(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x38(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x38(%rbp)
jmp    117a <main+0x5a>
mov    -0x30(%rbp),%rax
cmp    -0x20(%rbp),%rax
jbe    11c7 <main+0xa7>
mov    -0x30(%rbp),%rax
mov    %rax,-0x20(%rbp)
jmp    11cc <main+0xac>
mov    -0x34(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x34(%rbp)
jmp    115d <main+0x3d>
mov    -0x20(%rbp),%rsi
lea    0x1204(%rip),%rdi
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rax
mov    $0x37,%r9b
mov    $0xc,%eax
xor    %esi,%esi
lea    0xede(%rip),%rdx
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %rsi,%r8
movsbq %r9b,%rsi
add    $0xffffffffffffffd0,%rsi
movsbq -0xb(%rax,%rdx,1),%r9
mov    %r9,%rcx
add    $0xffffffffffffffd0,%rcx
imul   %rsi,%rcx
movsbq -0xa(%rax,%rdx,1),%rsi
add    $0xffffffffffffffd0,%rsi
movsbq -0x9(%rax,%rdx,1),%rdi
add    $0xffffffffffffffd0,%rdi
imul   %rsi,%rdi
imul   %rcx,%rdi
movsbq -0x8(%rax,%rdx,1),%rcx
add    $0xffffffffffffffd0,%rcx
movsbq -0x7(%rax,%rdx,1),%rsi
add    $0xffffffffffffffd0,%rsi
imul   %rcx,%rsi
movsbq -0x6(%rax,%rdx,1),%rcx
add    $0xffffffffffffffd0,%rcx
imul   %rsi,%rcx
imul   %rdi,%rcx
movsbq -0x5(%rax,%rdx,1),%rsi
add    $0xffffffffffffffd0,%rsi
movsbq -0x4(%rax,%rdx,1),%rdi
add    $0xffffffffffffffd0,%rdi
imul   %rsi,%rdi
movsbq -0x3(%rax,%rdx,1),%rsi
add    $0xffffffffffffffd0,%rsi
imul   %rdi,%rsi
movsbq -0x2(%rax,%rdx,1),%rdi
add    $0xffffffffffffffd0,%rdi
imul   %rsi,%rdi
imul   %rcx,%rdi
movsbq -0x1(%rax,%rdx,1),%rcx
add    $0xffffffffffffffd0,%rcx
movsbq (%rax,%rdx,1),%rsi
add    $0xffffffffffffffd0,%rsi
imul   %rcx,%rsi
imul   %rdi,%rsi
cmp    %r8,%rsi
cmovbe %r8,%rsi
add    $0x1,%rax
cmp    $0x3f4,%rax
jne    1130 <main+0x20>
lea    0x11e6(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
pop    %rcx
ret

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

LLVM IR (-O2):
@.str = [1001 x i8] c"7316717653133062491922511967442657474235534919493496983520312774506326239578318016984801869478851843858615607891129494954595017379583319528532088055111254069874715852386305071569329096329522744304355766896648950445244523161731856403098711121722383113622298934233803081353362766142828064444866452387493035890729629049156044077239071381051585930796086670172427121883998797908792274921901699720888093776657273330010533678812202354218097512545405947522435258490771167055601360483958644670632441572215539753697817977846174064955149290862569321978468622482839722413756570560574902614079729686524145351004748216637048440319989000889524345065854122758866688116427171479924442928230863465674813919123162824586178664583591245665294765456828489128831426076900422421902267105562632111110937054421750694165896040807198403850962455444362981230987879927244284909188845801561660979191338754992005240636899125607176060588611646710940507754100225698315520005593572972571636269561882670428252483600823257530420752963450\00"
@.str.1 = [22 x i8] c"Highest product: %lu\0A\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
br label %3
3: ; preds = %2, %3
%4 = phi i8 [ 55, %2 ], [ %11, %3 ]
%5 = phi i64 [ 0, %2 ], [ %9, %3 ]
%6 = phi i64 [ 0, %2 ], [ %82, %3 ]
%7 = sext i8 %4 to i64
%8 = add nsw i64 %7, -48
%9 = add nuw nsw i64 %5, 1
%10 = getelementptr inbounds [1001 x i8], [1001 x i8]* @.str, i64 0, i64 %9
%11 = load i8, i8* %10
%12 = sext i8 %11 to i64
%13 = add nsw i64 %12, -48
%14 = mul nsw i64 %13, %8
%15 = add nuw nsw i64 %5, 2
%16 = getelementptr inbounds [1001 x i8], [1001 x i8]* @.str, i64 0, i64 %15
%17 = load i8, i8* %16
%18 = sext i8 %17 to i64
%19 = add nsw i64 %18, -48
%20 = mul nsw i64 %19, %14
%21 = add nuw nsw i64 %5, 3
%22 = getelementptr inbounds [1001 x i8], [1001 x i8]* @.str, i64 0, i64 %21
%23 = load i8, i8* %22
%24 = sext i8 %23 to i64
%25 = add nsw i64 %24, -48
%26 = mul nsw i64 %25, %20
%27 = add nuw nsw i64 %5, 4
%28 = getelementptr inbounds [1001 x i8], [1001 x i8]* @.str, i64 0, i64 %27
%29 = load i8, i8* %28
%30 = sext i8 %29 to i64
%31 = add nsw i64 %30, -48
%32 = mul nsw i64 %31, %26
%33 = add nuw nsw i64 %5, 5
%34 = getelementptr inbounds [1001 x i8], [1001 x i8]* @.str, i64 0, i64 %33
%35 = load i8, i8* %34
%36 = sext i8 %35 to i64
%37 = add nsw i64 %36, -48
%38 = mul nsw i64 %37, %32
%39 = add nuw nsw i64 %5, 6
%40 = getelementptr inbounds [1001 x i8], [1001 x i8]* @.str, i64 0, i64 %39
%41 = load i8, i8* %40
%42 = sext i8 %41 to i64
%43 = add nsw i64 %42, -48
%44 = mul nsw i64 %43, %38
%45 = add nuw nsw i64 %5, 7
%46 = getelementptr inbounds [1001 x i8], [1001 x i8]* @.str, i64 0, i64 %45
%47 = load i8, i8* %46
%48 = sext i8 %47 to i64
%49 = add nsw i64 %48, -48
%50 = mul nsw i64 %49, %44
%51 = add nuw nsw i64 %5, 8
%52 = getelementptr inbounds [1001 x i8], [1001 x i8]* @.str, i64 0, i64 %51
%53 = load i8, i8* %52
%54 = sext i8 %53 to i64
%55 = add nsw i64 %54, -48
%56 = mul i64 %55, %50
%57 = add nuw nsw i64 %5, 9
%58 = getelementptr inbounds [1001 x i8], [1001 x i8]* @.str, i64 0, i64 %57
%59 = load i8, i8* %58
%60 = sext i8 %59 to i64
%61 = add nsw i64 %60, -48
%62 = mul i64 %61, %56
%63 = add nuw nsw i64 %5, 10
%64 = getelementptr inbounds [1001 x i8], [1001 x i8]* @.str, i64 0, i64 %63
%65 = load i8, i8* %64
%66 = sext i8 %65 to i64
%67 = add nsw i64 %66, -48
%68 = mul i64 %67, %62
%69 = add nuw nsw i64 %5, 11
%70 = getelementptr inbounds [1001 x i8], [1001 x i8]* @.str, i64 0, i64 %69
%71 = load i8, i8* %70
%72 = sext i8 %71 to i64
%73 = add nsw i64 %72, -48
%74 = mul i64 %73, %68
%75 = add nuw nsw i64 %5, 12
%76 = getelementptr inbounds [1001 x i8], [1001 x i8]* @.str, i64 0, i64 %75
%77 = load i8, i8* %76
%78 = sext i8 %77 to i64
%79 = add nsw i64 %78, -48
%80 = mul i64 %79, %74
%81 = icmp ugt i64 %80, %6
%82 = select i1 %81, i64 %80, i64 %6
%83 = icmp eq i64 %9, 1000
br i1 %83, label %84, label %3
84: ; preds = %3
%85 = tail call i32 @printf(i8* getelementptr inbounds ([22 x i8], [22 x i8]* @.str.1, i64 0, i64 0), i64 %82)
ret i32 0
}