#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*/ calculate_crc(unsigned char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *, unsigned char);
int main(int argc, char **argv) {
  unsigned char crc = 0;
  char *ch;
  int argidx = 1;
  if (argc == 1)
    return crc;
  for (; argidx < argc; argidx++) {
    ch = argv[argidx];
    while (*ch != 0)
      calculate_crc(&crc, *(ch++));
    printf("Word: %s  CRC(hex): %x\n", argv[argidx], crc);
  }
  return (int)crc;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
movb   $0x0,-0x11(%rbp)
movl   $0x1,-0x24(%rbp)
cmpl   $0x1,-0x8(%rbp)
jne    1157 <main+0x37>
movzbl -0x11(%rbp),%eax
mov    %eax,-0x4(%rbp)
jmp    11d9 <main+0xb9>
jmp    115c <main+0x3c>
mov    -0x24(%rbp),%eax
cmp    -0x8(%rbp),%eax
jge    11d2 <main+0xb2>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rax
movsbl (%rax),%eax
cmp    $0x0,%eax
je     11a8 <main+0x88>
mov    -0x20(%rbp),%rax
mov    %rax,%rcx
add    $0x1,%rcx
mov    %rcx,-0x20(%rbp)
movsbl (%rax),%esi
lea    -0x11(%rbp),%rdi
call   1030 <calculate_crc@plt>
jmp    1178 <main+0x58>
mov    -0x10(%rbp),%rax
movslq -0x24(%rbp),%rcx
mov    (%rax,%rcx,8),%rsi
lea    0xe45(%rip),%rdi
movzbl -0x11(%rbp),%edx
call   1040 <printf@plt>
mov    -0x24(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x24(%rbp)
jmp    115c <main+0x3c>
movzbl -0x11(%rbp),%eax
mov    %eax,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
movb   $0x0,0x7(%rsp)
xor    %eax,%eax
cmp    $0x2,%edi
jl     11a1 <main+0x81>
mov    %rsi,%r15
mov    %edi,%r13d
mov    $0x1,%ebp
lea    0xeb7(%rip),%r14
lea    0x7(%rsp),%r12
jmp    1169 <main+0x49>
movzbl 0x7(%rsp),%edx
mov    %r14,%rdi
mov    %rbx,%rsi
call   1040 <printf@plt>
add    $0x1,%rbp
cmp    %r13,%rbp
je     119c <main+0x7c>
mov    (%r15,%rbp,8),%rbx
mov    (%rbx),%al
test   %al,%al
je     1150 <main+0x30>
add    $0x1,%rbx
nopw   0x0(%rax,%rax,1)
movsbl %al,%esi
mov    %r12,%rdi
call   1030 <calculate_crc@plt>
movzbl (%rbx),%eax
add    $0x1,%rbx
test   %al,%al
jne    1180 <main+0x60>
mov    (%r15,%rbp,8),%rbx
jmp    1150 <main+0x30>
movzbl 0x7(%rsp),%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

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

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