#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*/ abort();
unsigned int shft_add(unsigned int, unsigned int);
int main(void) {
  unsigned int i = 0;
  unsigned int a = 0xdeadbeef;
  for (i = 0; i < 32; i++) {
    unsigned int exp = (a / (1 << i) + i);
    unsigned int got = shft_add(a, i);
    if (exp != got)
      abort();
  }
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
movl   $0x0,-0x8(%rbp)
movl   $0xdeadbeef,-0xc(%rbp)
movl   $0x0,-0x8(%rbp)
cmpl   $0x20,-0x8(%rbp)
jae    119b <main+0x7b>
mov    -0xc(%rbp),%eax
mov    -0x8(%rbp),%ecx
mov    $0x1,%edx
shl    %cl,%edx
mov    %edx,%ecx
xor    %edx,%edx
div    %ecx
add    -0x8(%rbp),%eax
mov    %eax,-0x10(%rbp)
mov    -0xc(%rbp),%edi
mov    -0x8(%rbp),%esi
call   1040 <shft_add@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%eax
cmp    -0x14(%rbp),%eax
je     1188 <main+0x68>
mov    $0x0,%al
call   1030 <abort@plt>
jmp    118d <main+0x6d>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    1144 <main+0x24>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
xor    %ebx,%ebx
cs nopw 0x0(%rax,%rax,1)
nop
mov    $0xdeadbeef,%ebp
mov    %ebx,%ecx
shr    %cl,%ebp
add    %ebx,%ebp
mov    $0xdeadbeef,%edi
mov    %ebx,%esi
call   1040 <shft_add@plt>
cmp    %eax,%ebp
jne    115c <main+0x3c>
add    $0x1,%ebx
cmp    $0x20,%ebx
jne    1130 <main+0x10>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
xor    %eax,%eax
call   1030 <abort@plt>

LLVM IR (-O0):
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %1
store i32 0, i32* %2
store i32 -559038737, i32* %3
store i32 0, i32* %2
br label %6
6: ; preds = %25, %0
%7 = load i32, i32* %2
%8 = icmp ult i32 %7, 32
br i1 %8, label %9, label %28
9: ; preds = %6
%10 = load i32, i32* %3
%11 = load i32, i32* %2
%12 = shl i32 1, %11
%13 = udiv i32 %10, %12
%14 = load i32, i32* %2
%15 = add i32 %13, %14
store i32 %15, i32* %4
%16 = load i32, i32* %3
%17 = load i32, i32* %2
%18 = call i32 @shft_add(i32 %16, i32 %17)
store i32 %18, i32* %5
%19 = load i32, i32* %4
%20 = load i32, i32* %5
%21 = icmp ne i32 %19, %20
br i1 %21, label %22, label %24
22: ; preds = %9
%23 = call i32 (...) @abort()
unreachable
24: ; preds = %9
br label %25
25: ; preds = %24
%26 = load i32, i32* %2
%27 = add i32 %26, 1
store i32 %27, i32* %2
br label %6
28: ; preds = %6
ret i32 0
}

LLVM IR (-O2):
define i32 @main() {
br label %4
1: ; preds = %4
%2 = add nuw nsw i32 %5, 1
%3 = icmp eq i32 %2, 32
br i1 %3, label %12, label %4
4: ; preds = %0, %1
%5 = phi i32 [ 0, %0 ], [ %2, %1 ]
%6 = lshr i32 -559038737, %5
%7 = add nuw i32 %6, %5
%8 = tail call i32 @shft_add(i32 -559038737, i32 %5)
%9 = icmp eq i32 %7, %8
br i1 %9, label %1, label %10
10: ; preds = %4
%11 = tail call i32 (...) @abort()
unreachable
12: ; preds = %1
ret i32 0
}