#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 */
unsigned char dow_crc(unsigned char const *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ strlen(char *);
int main(int argc, char *argv[]) {
  unsigned char crc;
  if (argc == 2) {
    crc = dow_crc((const unsigned char *)argv[1], strlen(argv[1]));
    printf("crc8: 0x%x\n", crc);
  } else {
    printf("Usage: %s <string>\n", argv[0]);
  }
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
cmpl   $0x2,-0x8(%rbp)
jne    118e <main+0x5e>
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1030 <strlen@plt>
mov    -0x20(%rbp),%rdi
mov    %eax,%esi
call   1050 <dow_crc@plt>
mov    %al,-0x11(%rbp)
movzbl -0x11(%rbp),%esi
lea    0xe7e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
jmp    11a3 <main+0x73>
mov    -0x10(%rbp),%rax
mov    (%rax),%rsi
lea    0xe70(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
cmp    $0x2,%edi
jne    115f <main+0x2f>
mov    0x8(%rsi),%rbx
mov    %rbx,%rdi
call   1030 <strlen@plt>
mov    %rbx,%rdi
mov    %eax,%esi
call   1050 <dow_crc@plt>
movzbl %al,%esi
lea    0xeaa(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
jmp    1170 <main+0x40>
mov    (%rsi),%rsi
lea    0xea3(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [12 x i8] c"crc8: 0x%x\0A\00"
@.str.1 = [20 x i8] c"Usage: %s <string>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%7 = load i32, i32* %4
%8 = icmp eq i32 %7, 2
br i1 %8, label %9, label %21
9: ; preds = %2
%10 = load i8**, i8*** %5
%11 = getelementptr inbounds i8*, i8** %10, i64 1
%12 = load i8*, i8** %11
%13 = load i8**, i8*** %5
%14 = getelementptr inbounds i8*, i8** %13, i64 1
%15 = load i8*, i8** %14
%16 = call i32 @strlen(i8* %15)
%17 = call zeroext i8 @dow_crc(i8* %12, i32 %16)
store i8 %17, i8* %6
%18 = load i8, i8* %6
%19 = zext i8 %18 to i32
%20 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %19)
br label %26
21: ; preds = %2
%22 = load i8**, i8*** %5
%23 = getelementptr inbounds i8*, i8** %22, i64 0
%24 = load i8*, i8** %23
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %24)
br label %26
26: ; preds = %21, %9
%27 = load i32, i32* %3
ret i32 %27
}

LLVM IR (-O2):
@.str = [12 x i8] c"crc8: 0x%x\0A\00"
@.str.1 = [20 x i8] c"Usage: %s <string>\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = icmp eq i32 %0, 2
br i1 %3, label %4, label %11
4: ; preds = %2
%5 = getelementptr inbounds i8*, i8** %1, i64 1
%6 = load i8*, i8** %5
%7 = tail call i32 @strlen(i8* %6)
%8 = tail call zeroext i8 @dow_crc(i8* %6, i32 %7)
%9 = zext i8 %8 to i32
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str, i64 0, i64 0), i32 %9)
br label %14
11: ; preds = %2
%12 = load i8*, i8** %1
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([20 x i8], [20 x i8]* @.str.1, i64 0, i64 0), i8* %12)
br label %14
14: ; preds = %11, %4
ret i32 0
}