#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 EXIT_SUCCESS;
int /*<<< orphan*/ pow(int, int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ snprintf(char *, int, char *, int /*<<< orphan*/);
int main(int argc, char *argv[]) {
  char digits[303] = {0};
  snprintf(digits, 303, "%lf", pow(2, 1000));
  int i, sum = 0;
  for (i = 0; i < 302; i++) {
    sum += digits[i] - '0';
  }
  printf("Solution: %d.\n", sum);
  return EXIT_SUCCESS;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x150,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
lea    -0x140(%rbp),%rdi
xor    %esi,%esi
mov    $0x12f,%edx
call   1050 <memset@plt>
lea    -0x140(%rbp),%rax
mov    %rax,-0x150(%rbp)
mov    $0x2,%edi
mov    $0x3e8,%esi
call   1060 <pow@plt>
mov    -0x150(%rbp),%rdi
mov    %eax,%ecx
mov    $0x12f,%esi
lea    0xe62(%rip),%rdx
call   1040 <snprintf@plt>
movl   $0x0,-0x148(%rbp)
movl   $0x0,-0x144(%rbp)
cmpl   $0x12e,-0x144(%rbp)
jge    11f9 <main+0xb9>
movslq -0x144(%rbp),%rax
movsbl -0x140(%rbp,%rax,1),%eax
ff
sub    $0x30,%eax
add    -0x148(%rbp),%eax
mov    %eax,-0x148(%rbp)
mov    -0x144(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x144(%rbp)
jmp    11b7 <main+0x77>
mov    -0x148(%rbp),%esi
lea    0xdfe(%rip),%rdi
call   1030 <printf@plt>
mov    0x2dce(%rip),%rax
mov    (%rax),%eax
add    $0x150,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x130,%rsp
mov    %rsp,%rbx
mov    $0x12f,%edx
mov    %rbx,%rdi
xor    %esi,%esi
call   1050 <memset@plt>
mov    $0x2,%edi
mov    $0x3e8,%esi
call   1060 <pow@plt>
lea    0xea0(%rip),%rdx
mov    %rbx,%rdi
mov    $0x12f,%esi
mov    %eax,%ecx
call   1040 <snprintf@plt>
pxor   %xmm0,%xmm0
mov    $0xc,%eax
movdqa 0xe70(%rip),%xmm2
pxor   %xmm1,%xmm1
cs nopw 0x0(%rax,%rax,1)
xchg   %ax,%ax
movd   -0x8(%rsp,%rax,1),%xmm3
punpcklbw %xmm3,%xmm3
punpcklwd %xmm3,%xmm3
punpcklbw -0xc(%rsp,%rax,1),%xmm4
punpcklwd %xmm4,%xmm4
psrad  $0x18,%xmm4
psrad  $0x18,%xmm3
paddd  %xmm2,%xmm0
paddd  %xmm4,%xmm0
paddd  %xmm2,%xmm1
paddd  %xmm3,%xmm1
cmp    $0x12c,%rax
je     1215 <main+0xd5>
movq   -0x4(%rsp,%rax,1),%xmm3
punpcklbw %xmm3,%xmm3
punpcklwd %xmm3,%xmm3
movd   (%rsp,%rax,1),%xmm4
punpcklbw %xmm4,%xmm4
punpcklwd %xmm4,%xmm4
psrad  $0x18,%xmm3
psrad  $0x18,%xmm4
paddd  %xmm3,%xmm0
paddd  %xmm4,%xmm1
paddd  %xmm2,%xmm0
paddd  %xmm2,%xmm1
add    $0x10,%rax
jmp    11a0 <main+0x60>
paddd  %xmm0,%xmm1
pshufd $0xee,%xmm1,%xmm0
paddd  %xmm1,%xmm0
pshufd $0x55,%xmm0,%xmm1
paddd  %xmm0,%xmm1
movd   %xmm1,%eax
movsbl 0x128(%rsp),%ecx
add    %eax,%ecx
movsbl 0x129(%rsp),%eax
add    %ecx,%eax
movsbl 0x12a(%rsp),%ecx
add    %eax,%ecx
movsbl 0x12b(%rsp),%eax
add    %ecx,%eax
movsbl 0x12c(%rsp),%ecx
add    %eax,%ecx
movsbl 0x12d(%rsp),%eax
lea    (%rax,%rcx,1),%esi
add    $0xfffffee0,%esi
lea    0xd9b(%rip),%rdi
call   1030 <printf@plt>
mov    0x2d5b(%rip),%rax
mov    (%rax),%eax
add    $0x130,%rsp
pop    %rbx
ret

LLVM IR (-O0):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [15 x i8] c"Solution: %d.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca [303 x i8]
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = bitcast [303 x i8]* %6 to i8*
%10 = getelementptr inbounds [303 x i8], [303 x i8]* %6, i64 0, i64 0
%11 = call i32 @pow(i32 2, i32 1000)
%12 = call i32 @snprintf(i8* %10, i32 303, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %11)
store i32 0, i32* %8
store i32 0, i32* %7
br label %13
13: ; preds = %25, %2
%14 = load i32, i32* %7
%15 = icmp slt i32 %14, 302
br i1 %15, label %16, label %28
16: ; preds = %13
%17 = load i32, i32* %7
%18 = sext i32 %17 to i64
%19 = getelementptr inbounds [303 x i8], [303 x i8]* %6, i64 0, i64 %18
%20 = load i8, i8* %19
%21 = sext i8 %20 to i32
%22 = sub nsw i32 %21, 48
%23 = load i32, i32* %8
%24 = add nsw i32 %23, %22
store i32 %24, i32* %8
br label %25
25: ; preds = %16
%26 = load i32, i32* %7
%27 = add nsw i32 %26, 1
store i32 %27, i32* %7
br label %13
28: ; preds = %13
%29 = load i32, i32* %8
%30 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %29)
%31 = load i32, i32* @EXIT_SUCCESS
ret i32 %31
}

LLVM IR (-O2):
@.str = [4 x i8] c"%lf\00"
@.str.1 = [15 x i8] c"Solution: %d.\0A\00"
@EXIT_SUCCESS = global i32 0
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca [303 x i8]
%4 = getelementptr inbounds [303 x i8], [303 x i8]* %3, i64 0, i64 0
%5 = tail call i32 @pow(i32 2, i32 1000)
%6 = call i32 @snprintf(i8* %4, i32 303, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i32 %5)
br label %7
7: ; preds = %25, %2
%8 = phi i64 [ 0, %2 ], [ %38, %25 ]
%9 = phi <4 x i32> [ zeroinitializer, %2 ], [ %36, %25 ]
%10 = phi <4 x i32> [ zeroinitializer, %2 ], [ %37, %25 ]
%11 = getelementptr inbounds [303 x i8], [303 x i8]* %3, i64 0, i64 %8
%12 = bitcast i8* %11 to <4 x i8>*
%13 = load <4 x i8>, <4 x i8>* %12
%14 = getelementptr inbounds i8, i8* %11, i64 4
%15 = bitcast i8* %14 to <4 x i8>*
%16 = load <4 x i8>, <4 x i8>* %15
%17 = sext <4 x i8> %13 to <4 x i32>
%18 = sext <4 x i8> %16 to <4 x i32>
%19 = add <4 x i32> %9, <i32 -48, i32 -48, i32 -48, i32 -48>
%20 = add <4 x i32> %10, <i32 -48, i32 -48, i32 -48, i32 -48>
%21 = add <4 x i32> %19, %17
%22 = add <4 x i32> %20, %18
%23 = or i64 %8, 8
%24 = icmp eq i64 %23, 296
br i1 %24, label %39, label %25
25: ; preds = %7
%26 = getelementptr inbounds [303 x i8], [303 x i8]* %3, i64 0, i64 %23
%27 = bitcast i8* %26 to <4 x i8>*
%28 = load <4 x i8>, <4 x i8>* %27
%29 = getelementptr inbounds i8, i8* %26, i64 4
%30 = bitcast i8* %29 to <4 x i8>*
%31 = load <4 x i8>, <4 x i8>* %30
%32 = sext <4 x i8> %28 to <4 x i32>
%33 = sext <4 x i8> %31 to <4 x i32>
%34 = add <4 x i32> %21, <i32 -48, i32 -48, i32 -48, i32 -48>
%35 = add <4 x i32> %22, <i32 -48, i32 -48, i32 -48, i32 -48>
%36 = add <4 x i32> %34, %32
%37 = add <4 x i32> %35, %33
%38 = add nuw nsw i64 %8, 16
br label %7
39: ; preds = %7
%40 = add <4 x i32> %22, %21
%41 = call i32 @llvm.vector.reduce.add.v4i32(<4 x i32> %40)
%42 = getelementptr inbounds [303 x i8], [303 x i8]* %3, i64 0, i64 296
%43 = load i8, i8* %42
%44 = sext i8 %43 to i32
%45 = add i32 %41, -48
%46 = add i32 %45, %44
%47 = getelementptr inbounds [303 x i8], [303 x i8]* %3, i64 0, i64 297
%48 = load i8, i8* %47
%49 = sext i8 %48 to i32
%50 = add i32 %46, -48
%51 = add i32 %50, %49
%52 = getelementptr inbounds [303 x i8], [303 x i8]* %3, i64 0, i64 298
%53 = load i8, i8* %52
%54 = sext i8 %53 to i32
%55 = add i32 %51, -48
%56 = add i32 %55, %54
%57 = getelementptr inbounds [303 x i8], [303 x i8]* %3, i64 0, i64 299
%58 = load i8, i8* %57
%59 = sext i8 %58 to i32
%60 = add i32 %56, -48
%61 = add i32 %60, %59
%62 = getelementptr inbounds [303 x i8], [303 x i8]* %3, i64 0, i64 300
%63 = load i8, i8* %62
%64 = sext i8 %63 to i32
%65 = add i32 %61, -48
%66 = add i32 %65, %64
%67 = getelementptr inbounds [303 x i8], [303 x i8]* %3, i64 0, i64 301
%68 = load i8, i8* %67
%69 = sext i8 %68 to i32
%70 = add i32 %66, -48
%71 = add i32 %70, %69
%72 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %71)
%73 = load i32, i32* @EXIT_SUCCESS
ret i32 %73
}