#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 */
typedef scalar_t__ uint32_t;

/* Variables and functions */
int /*<<< orphan*/ memset(char *, int /*<<< orphan*/, int);
int /*<<< orphan*/ printf(char *, int);
int scanf(char *, char *);
int singletable_crc32c(scalar_t__, char *, int /*<<< orphan*/);
int /*<<< orphan*/ strlen(char *);
int main() {
  uint32_t crc = 0;
  char user_input[42] = {0};
  while (scanf("%s", user_input) == 1) {
    crc = 0;
    printf("%#0x\n", singletable_crc32c(crc, user_input, strlen(user_input)));
    memset(user_input, 0, 42);
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
movl   $0x0,-0x4(%rbp)
movq   $0x0,-0x10(%rbp)
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x2a,%edx
call   1060 <memset@plt>
lea    -0x40(%rbp),%rsi
lea    0xe7e(%rip),%rdi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11e3 <main+0x93>
movq   $0x0,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x50(%rbp)
lea    -0x40(%rbp),%rax
mov    %rax,-0x48(%rbp)
lea    -0x40(%rbp),%rdi
call   1030 <strlen@plt>
mov    -0x50(%rbp),%rdi
mov    -0x48(%rbp),%rsi
mov    %eax,%edx
call   1050 <singletable_crc32c@plt>
mov    %eax,%esi
lea    0xe3a(%rip),%rdi
call   1040 <printf@plt>
lea    -0x40(%rbp),%rdi
xor    %esi,%esi
mov    $0x2a,%edx
call   1060 <memset@plt>
jmp    1177 <main+0x27>
xor    %eax,%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r15
push   %r14
push   %rbx
sub    $0x30,%rsp
xorps  %xmm0,%xmm0
movups %xmm0,0x1a(%rsp)
movaps %xmm0,0x10(%rsp)
movaps %xmm0,(%rsp)
lea    0xe8f(%rip),%rdi
mov    %rsp,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
jne    11cd <main+0x7d>
mov    %rsp,%rbx
lea    0xe7b(%rip),%r14
lea    0xe71(%rip),%r15
nop
mov    %rbx,%rdi
call   1030 <strlen@plt>
xor    %edi,%edi
mov    %rbx,%rsi
mov    %eax,%edx
call   1050 <singletable_crc32c@plt>
mov    %r14,%rdi
mov    %eax,%esi
call   1040 <printf@plt>
mov    %rbx,%rdi
xor    %esi,%esi
mov    $0x2a,%edx
call   1060 <memset@plt>
mov    %r15,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
cmp    $0x1,%eax
je     1190 <main+0x40>
xor    %eax,%eax
add    $0x30,%rsp
pop    %rbx
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
@.str = [3 x i8] c"%s\00"
@.str.1 = [6 x i8] c"%x\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i64
%3 = alloca [42 x i8]
store i32 0, i32* %1
store i64 0, i64* %2
%4 = bitcast [42 x i8]* %3 to i8*
br label %5
5: ; preds = %9, %0
%6 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 0
%7 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %6)
%8 = icmp eq i32 %7, 1
br i1 %8, label %9, label %18
9: ; preds = %5
store i64 0, i64* %2
%10 = load i64, i64* %2
%11 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 0
%12 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 0
%13 = call i32 @strlen(i8* %12)
%14 = call i32 @singletable_crc32c(i64 %10, i8* %11, i32 %13)
%15 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %14)
%16 = getelementptr inbounds [42 x i8], [42 x i8]* %3, i64 0, i64 0
%17 = call i32 @memset(i8* %16, i32 0, i32 42)
br label %5
18: ; preds = %5
ret i32 0
}

LLVM IR (-O2):
@.str = [3 x i8] c"%s\00"
@.str.1 = [6 x i8] c"%x\0A\00"
define i32 @main() {
%1 = alloca [42 x i8]
%2 = getelementptr inbounds [42 x i8], [42 x i8]* %1, i64 0, i64 0
%3 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = icmp eq i32 %3, 1
br i1 %4, label %5, label %12
5: ; preds = %0, %5
%6 = call i32 @strlen(i8* %2)
%7 = call i32 @singletable_crc32c(i64 0, i8* %2, i32 %6)
%8 = call i32 @printf(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%9 = call i32 @memset(i8* %2, i32 0, i32 42)
%10 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str, i64 0, i64 0), i8* %2)
%11 = icmp eq i32 %10, 1
br i1 %11, label %5, label %12
12: ; preds = %5, %0
ret i32 0
}