#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 int uint32_t;

/* Variables and functions */
int /*<<< orphan*/ printf(char *, size_t, int, int);
void test_untemper(const uint32_t val) {
  size_t i;
  uint32_t temp_steps[5], untemp_steps[5];
  temp_steps[0] = val;
  temp_steps[1] = temp_steps[0] ^ (temp_steps[0] >> 11);
  temp_steps[2] = temp_steps[1] ^ ((temp_steps[1] << 7) & (0x9d2c5680));
  temp_steps[3] = temp_steps[2] ^ ((temp_steps[2] << 15) & (0xefc60000));
  temp_steps[4] = temp_steps[3] ^ (temp_steps[3] >> 18);
  untemp_steps[0] = temp_steps[4];
  untemp_steps[1] = untemp_steps[0] ^ (untemp_steps[0] >> 18);
  untemp_steps[2] =
      (untemp_steps[1]) ^ ((untemp_steps[1] << 15) & (0xefc60000));
  untemp_steps[3] =
      (untemp_steps[2]) ^ ((untemp_steps[2] << 7) & (0x9d2c5680)) ^
      ((((untemp_steps[2] << 7) & (0x9d2c5680)) << 7) & (0x9d2c5680)) ^
      ((((((untemp_steps[2] << 7) & (0x9d2c5680)) << 7) & (0x9d2c5680)) << 7) &
       (0x9d2c5680)) ^
      ((((((((untemp_steps[2] << 7) & (0x9d2c5680)) << 7) & (0x9d2c5680))
          << 7) &
         (0x9d2c5680))
        << 7) &
       (0x9d2c5680));
  untemp_steps[4] =
      untemp_steps[3] ^ (untemp_steps[3] >> 11) ^ (untemp_steps[3] >> 22);
  for (i = 0; i < 5; i++)
    if (untemp_steps[4] != temp_steps[0])
      printf("Tempering steps %zu: 0x%02x - 0x%02x \n", i, temp_steps[i],
             untemp_steps[4 - i]);
}


x86 assembly (clang, -O0):
<test_untemper>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    -0x4(%rbp),%eax
mov    %eax,-0x30(%rbp)
mov    -0x30(%rbp),%eax
mov    -0x30(%rbp),%ecx
sar    $0xb,%ecx
xor    %ecx,%eax
mov    %eax,-0x2c(%rbp)
mov    -0x2c(%rbp),%eax
mov    -0x2c(%rbp),%ecx
shl    $0x7,%ecx
and    $0x9d2c5680,%ecx
xor    %ecx,%eax
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%eax
mov    -0x28(%rbp),%ecx
shl    $0xf,%ecx
and    $0xefc60000,%ecx
xor    %ecx,%eax
mov    %eax,-0x24(%rbp)
mov    -0x24(%rbp),%eax
mov    -0x24(%rbp),%ecx
sar    $0x12,%ecx
xor    %ecx,%eax
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%eax
mov    %eax,-0x50(%rbp)
mov    -0x50(%rbp),%eax
mov    -0x50(%rbp),%ecx
sar    $0x12,%ecx
xor    %ecx,%eax
mov    %eax,-0x4c(%rbp)
mov    -0x4c(%rbp),%eax
mov    -0x4c(%rbp),%ecx
shl    $0xf,%ecx
and    $0xefc60000,%ecx
xor    %ecx,%eax
mov    %eax,-0x48(%rbp)
mov    -0x48(%rbp),%eax
mov    -0x48(%rbp),%ecx
shl    $0x7,%ecx
and    $0x9d2c5680,%ecx
xor    %ecx,%eax
mov    -0x48(%rbp),%ecx
shl    $0x7,%ecx
and    $0x9d2c5680,%ecx
shl    $0x7,%ecx
and    $0x9d2c5680,%ecx
xor    %ecx,%eax
mov    -0x48(%rbp),%ecx
shl    $0x7,%ecx
and    $0x9d2c5680,%ecx
shl    $0x7,%ecx
and    $0x9d2c5680,%ecx
shl    $0x7,%ecx
and    $0x9d2c5680,%ecx
xor    %ecx,%eax
mov    -0x48(%rbp),%ecx
shl    $0x7,%ecx
and    $0x9d2c5680,%ecx
shl    $0x7,%ecx
and    $0x9d2c5680,%ecx
shl    $0x7,%ecx
and    $0x9d2c5680,%ecx
shl    $0x7,%ecx
and    $0x9d2c5680,%ecx
xor    %ecx,%eax
mov    %eax,-0x44(%rbp)
mov    -0x44(%rbp),%eax
mov    -0x44(%rbp),%ecx
sar    $0xb,%ecx
xor    %ecx,%eax
mov    -0x44(%rbp),%ecx
sar    $0x16,%ecx
xor    %ecx,%eax
mov    %eax,-0x40(%rbp)
movq   $0x0,-0x10(%rbp)
cmpq   $0x5,-0x10(%rbp)
jae    1271 <test_untemper+0x161>
mov    -0x40(%rbp),%eax
cmp    -0x30(%rbp),%eax
je     125b <test_untemper+0x14b>
mov    -0x10(%rbp),%rsi
mov    -0x10(%rbp),%rax
mov    -0x30(%rbp,%rax,4),%edx
mov    $0x4,%eax
sub    -0x10(%rbp),%rax
mov    -0x50(%rbp,%rax,4),%ecx
lea    0xdaa(%rip),%rdi
call   1030 <printf@plt>
jmp    1260 <test_untemper+0x150>
mov    -0x10(%rbp),%rax
add    $0x1,%rax
mov    %rax,-0x10(%rbp)
jmp    121f <test_untemper+0x10f>
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_untemper>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%r15d
sar    $0xb,%r15d
xor    %edi,%r15d
mov    %r15d,%ebp
shl    $0x7,%ebp
and    $0x9d2c5680,%ebp
xor    %r15d,%ebp
mov    %ebp,%r13d
shl    $0xf,%r13d
and    $0xefc60000,%r13d
xor    %ebp,%r13d
mov    %r13d,%esi
sar    $0x12,%esi
xor    %r13d,%esi
mov    %esi,%r14d
sar    $0x12,%r14d
xor    %esi,%r14d
mov    %r14d,%r12d
shl    $0xf,%r12d
and    $0xefc60000,%r12d
xor    %r14d,%r12d
mov    %r12d,%eax
shl    $0x7,%eax
and    $0x9d2c5680,%eax
xor    %r12d,%eax
mov    %r12d,%ebx
shl    $0xe,%ebx
and    $0x94284000,%ebx
xor    %ebx,%eax
mov    %ebx,%ecx
shl    $0x7,%ecx
shl    $0xe,%ebx
xor    %ecx,%ebx
xor    %eax,%ebx
mov    %ebx,%eax
sar    $0xb,%eax
xor    %ebx,%eax
mov    %ebx,%ecx
sar    $0x16,%ecx
xor    %eax,%ecx
cmp    %edi,%ecx
jne    11b2 <test_untemper+0xa2>
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    %edi,%edx
lea    0xe45(%rip),%rdi
mov    %esi,0x4(%rsp)
xor    %esi,%esi
call   1030 <printf@plt>
mov    $0x1,%esi
lea    0xe2e(%rip),%rdi
mov    %r15d,%edx
mov    %ebx,%ecx
call   1030 <printf@plt>
mov    $0x2,%esi
lea    0xe18(%rip),%rbx
mov    %rbx,%rdi
mov    %ebp,%edx
mov    %r12d,%ecx
call   1030 <printf@plt>
mov    $0x3,%esi
mov    %rbx,%rdi
mov    %r13d,%edx
mov    %r14d,%ecx
call   1030 <printf@plt>
mov    $0x4,%esi
mov    %rbx,%rdi
mov    0x4(%rsp),%ecx
mov    %ecx,%edx
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
jmp    1030 <printf@plt>

LLVM IR (-O0):
@.str = [39 x i8] c"Tempering steps %zu: 0x%02x - 0x%02x \0A\00"
define void @test_untemper(i32 %0) {
%2 = alloca i32
%3 = alloca i64
%4 = alloca [5 x i32]
%5 = alloca [5 x i32]
store i32 %0, i32* %2
%6 = load i32, i32* %2
%7 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
store i32 %6, i32* %7
%8 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%9 = load i32, i32* %8
%10 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%11 = load i32, i32* %10
%12 = ashr i32 %11, 11
%13 = xor i32 %9, %12
%14 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 1
store i32 %13, i32* %14
%15 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 1
%16 = load i32, i32* %15
%17 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 1
%18 = load i32, i32* %17
%19 = shl i32 %18, 7
%20 = and i32 %19, -1658038656
%21 = xor i32 %16, %20
%22 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 2
store i32 %21, i32* %22
%23 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 2
%24 = load i32, i32* %23
%25 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 2
%26 = load i32, i32* %25
%27 = shl i32 %26, 15
%28 = and i32 %27, -272236544
%29 = xor i32 %24, %28
%30 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 3
store i32 %29, i32* %30
%31 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 3
%32 = load i32, i32* %31
%33 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 3
%34 = load i32, i32* %33
%35 = ashr i32 %34, 18
%36 = xor i32 %32, %35
%37 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 4
store i32 %36, i32* %37
%38 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 4
%39 = load i32, i32* %38
%40 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
store i32 %39, i32* %40
%41 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
%42 = load i32, i32* %41
%43 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 0
%44 = load i32, i32* %43
%45 = ashr i32 %44, 18
%46 = xor i32 %42, %45
%47 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 1
store i32 %46, i32* %47
%48 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 1
%49 = load i32, i32* %48
%50 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 1
%51 = load i32, i32* %50
%52 = shl i32 %51, 15
%53 = and i32 %52, -272236544
%54 = xor i32 %49, %53
%55 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 2
store i32 %54, i32* %55
%56 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 2
%57 = load i32, i32* %56
%58 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 2
%59 = load i32, i32* %58
%60 = shl i32 %59, 7
%61 = and i32 %60, -1658038656
%62 = xor i32 %57, %61
%63 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 2
%64 = load i32, i32* %63
%65 = shl i32 %64, 7
%66 = and i32 %65, -1658038656
%67 = shl i32 %66, 7
%68 = and i32 %67, -1658038656
%69 = xor i32 %62, %68
%70 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 2
%71 = load i32, i32* %70
%72 = shl i32 %71, 7
%73 = and i32 %72, -1658038656
%74 = shl i32 %73, 7
%75 = and i32 %74, -1658038656
%76 = shl i32 %75, 7
%77 = and i32 %76, -1658038656
%78 = xor i32 %69, %77
%79 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 2
%80 = load i32, i32* %79
%81 = shl i32 %80, 7
%82 = and i32 %81, -1658038656
%83 = shl i32 %82, 7
%84 = and i32 %83, -1658038656
%85 = shl i32 %84, 7
%86 = and i32 %85, -1658038656
%87 = shl i32 %86, 7
%88 = and i32 %87, -1658038656
%89 = xor i32 %78, %88
%90 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 3
store i32 %89, i32* %90
%91 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 3
%92 = load i32, i32* %91
%93 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 3
%94 = load i32, i32* %93
%95 = ashr i32 %94, 11
%96 = xor i32 %92, %95
%97 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 3
%98 = load i32, i32* %97
%99 = ashr i32 %98, 22
%100 = xor i32 %96, %99
%101 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 4
store i32 %100, i32* %101
store i64 0, i64* %3
br label %102
102: ; preds = %122, %1
%103 = load i64, i64* %3
%104 = icmp ult i64 %103, 5
br i1 %104, label %105, label %125
105: ; preds = %102
%106 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 4
%107 = load i32, i32* %106
%108 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 0
%109 = load i32, i32* %108
%110 = icmp ne i32 %107, %109
br i1 %110, label %111, label %121
111: ; preds = %105
%112 = load i64, i64* %3
%113 = load i64, i64* %3
%114 = getelementptr inbounds [5 x i32], [5 x i32]* %4, i64 0, i64 %113
%115 = load i32, i32* %114
%116 = load i64, i64* %3
%117 = sub i64 4, %116
%118 = getelementptr inbounds [5 x i32], [5 x i32]* %5, i64 0, i64 %117
%119 = load i32, i32* %118
%120 = call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i64 %112, i32 %115, i32 %119)
br label %121
121: ; preds = %111, %105
br label %122
122: ; preds = %121
%123 = load i64, i64* %3
%124 = add i64 %123, 1
store i64 %124, i64* %3
br label %102
125: ; preds = %102
ret void
}

LLVM IR (-O2):
@.str = [39 x i8] c"Tempering steps %zu: 0x%02x - 0x%02x \0A\00"
define void @test_untemper(i32 %0) {
%2 = ashr i32 %0, 11
%3 = xor i32 %2, %0
%4 = shl i32 %3, 7
%5 = and i32 %4, -1658038656
%6 = xor i32 %5, %3
%7 = shl i32 %6, 15
%8 = and i32 %7, -272236544
%9 = xor i32 %8, %6
%10 = ashr i32 %9, 18
%11 = xor i32 %10, %9
%12 = ashr i32 %11, 18
%13 = xor i32 %12, %11
%14 = shl i32 %13, 15
%15 = and i32 %14, -272236544
%16 = xor i32 %15, %13
%17 = shl i32 %16, 7
%18 = and i32 %17, -1658038656
%19 = xor i32 %18, %16
%20 = shl i32 %16, 14
%21 = and i32 %20, -1809301504
%22 = xor i32 %19, %21
%23 = shl i32 %21, 7
%24 = xor i32 %22, %23
%25 = shl i32 %21, 14
%26 = xor i32 %24, %25
%27 = ashr i32 %26, 11
%28 = xor i32 %27, %26
%29 = ashr i32 %26, 22
%30 = xor i32 %28, %29
%31 = icmp eq i32 %30, %0
br i1 %31, label %38, label %32
32: ; preds = %1
%33 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i64 0, i32 %0, i32 %30)
%34 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i64 1, i32 %3, i32 %26)
%35 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i64 2, i32 %6, i32 %16)
%36 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i64 3, i32 %9, i32 %13)
%37 = tail call i32 @printf(i8* getelementptr inbounds ([39 x i8], [39 x i8]* @.str, i64 0, i64 0), i64 4, i32 %11, i32 %11)
br label %38
38: ; preds = %1, %32
ret void
}