#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 checksum(unsigned short *, int);
int /*<<< orphan*/ memset(unsigned char **, int, int);
int /*<<< orphan*/ printf(char *, int, ...);
int strlen(char *);
int main(int argc, char **argv) {
  if (argc == 1) {
    unsigned char even[16];
    unsigned char odd[17];
    memset(&even, 81, 16);
    memset(&odd, 81, 17);
    printf("even input size: %d\n", checksum((unsigned short *)&even, 16));
    printf("odd  input size: %d\n", checksum((unsigned short *)&odd, 17));
    return 0;
  }
  for (int i = 1; i < argc; ++i)
    printf("%d\t%s\n", checksum((unsigned short *)argv[i], strlen(argv[i])),
           argv[i]);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    11ce <main+0x8e>
lea    -0x20(%rbp),%rdi
mov    $0x51,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    -0x40(%rbp),%rdi
mov    $0x51,%esi
mov    $0x11,%edx
call   1060 <memset@plt>
lea    -0x20(%rbp),%rdi
mov    $0x10,%esi
call   1050 <checksum@plt>
mov    %eax,%esi
lea    0xe63(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
mov    $0x11,%esi
call   1050 <checksum@plt>
mov    %eax,%esi
lea    0xe5a(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
jmp    123e <main+0xfe>
movl   $0x1,-0x44(%rbp)
mov    -0x44(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    1237 <main+0xf7>
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x50(%rbp)
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rdi
call   1030 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    %eax,%esi
call   1050 <checksum@plt>
mov    %eax,%esi
mov    -0x10(%rbp),%rax
movslq -0x44(%rbp),%rcx
mov    (%rax,%rcx,8),%rdx
lea    0xe08(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    11d5 <main+0x95>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x30,%rsp
cmp    $0x1,%edi
jne    11ba <main+0x7a>
mov    %rsp,%rbx
mov    %rbx,%rdi
mov    $0x51,%esi
mov    $0x10,%edx
call   1060 <memset@plt>
lea    0x10(%rsp),%r14
mov    %r14,%rdi
mov    $0x51,%esi
mov    $0x11,%edx
call   1060 <memset@plt>
mov    %rbx,%rdi
mov    $0x10,%esi
call   1050 <checksum@plt>
lea    0xe6e(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %r14,%rdi
mov    $0x11,%esi
call   1050 <checksum@plt>
lea    0xe66(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    11ff <main+0xbf>
jle    11ff <main+0xbf>
mov    %rsi,%r15
mov    %edi,%r12d
mov    $0x1,%ebx
lea    0xe5c(%rip),%r14
xchg   %ax,%ax
mov    (%r15,%rbx,8),%r13
mov    %r13,%rdi
call   1030 <strlen@plt>
mov    %r13,%rdi
mov    %eax,%esi
call   1050 <checksum@plt>
mov    (%r15,%rbx,8),%rdx
mov    %r14,%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1040 <printf@plt>
add    $0x1,%rbx
cmp    %rbx,%r12
jne    11d0 <main+0x90>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
ret

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

LLVM IR (-O2):
@.str = [21 x i8] c"even input size: %d\0A\00"
@.str.1 = [21 x i8] c"odd input size: %d\0A\00"
@.str.2 = [7 x i8] c"%d\09%s\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca [16 x i8]
%4 = alloca [17 x i8]
%5 = icmp eq i32 %0, 1
br i1 %5, label %10, label %6
6: ; preds = %2
%7 = icmp sgt i32 %0, 1
br i1 %7, label %8, label %34
8: ; preds = %6
%9 = zext i32 %0 to i64
br label %23
10: ; preds = %2
%11 = getelementptr inbounds [16 x i8], [16 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [17 x i8], [17 x i8]* %4, i64 0, i64 0
%13 = bitcast [16 x i8]* %3 to i8**
%14 = call i32 @memset(i8** %13, i32 81, i32 16)
%15 = bitcast [17 x i8]* %4 to i8**
%16 = call i32 @memset(i8** %15, i32 81, i32 17)
%17 = bitcast [16 x i8]* %3 to i16*
%18 = call i32 @checksum(i16* %17, i32 16)
%19 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i32 %18)
%20 = bitcast [17 x i8]* %4 to i16*
%21 = call i32 @checksum(i16* %20, i32 17)
%22 = call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.1, i64 0, i64 0), i32 %21)
br label %34
23: ; preds = %8, %23
%24 = phi i64 [ 1, %8 ], [ %32, %23 ]
%25 = getelementptr inbounds i8*, i8** %1, i64 %24
%26 = load i8*, i8** %25
%27 = bitcast i8* %26 to i16*
%28 = tail call i32 @strlen(i8* %26)
%29 = tail call i32 @checksum(i16* %27, i32 %28)
%30 = load i8*, i8** %25
%31 = tail call i32 (i8*, i32, ...) @printf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.2, i64 0, i64 0), i32 %29, i8* %30)
%32 = add nuw nsw i64 %24, 1
%33 = icmp eq i64 %32, %9
br i1 %33, label %34, label %23
34: ; preds = %23, %6, %10
ret i32 0
}