#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*/ printf(char *);
int logical(int a, int b) {
  int c, d, e, f, g, h;
  unsigned long long cc, dd;
  unsigned long ee, ff;
  int i;
  for (i = 0; i < 5010; ++i) {
    c = a & b;
    cc = (unsigned long long)c;
    ee = cc >> 32;
    ff = cc << 32;
    ee = (unsigned long)c;
    dd = ee | ff;
  }
  if (cc == dd)
    printf("cc and dd is the same!\n");
  return c;
}


x86 assembly (clang, -O0):
<logical>:
push   %rbp
mov    %rsp,%rbp
sub    $0x50,%rsp
mov    %edi,-0x4(%rbp)
mov    %esi,-0x8(%rbp)
movl   $0x0,-0x44(%rbp)
cmpl   $0x1392,-0x44(%rbp)
jge    117d <logical+0x6d>
mov    -0x4(%rbp),%eax
and    -0x8(%rbp),%eax
mov    %eax,-0xc(%rbp)
movslq -0xc(%rbp),%rax
mov    %rax,-0x28(%rbp)
mov    -0x28(%rbp),%rax
shr    $0x20,%rax
mov    %rax,-0x38(%rbp)
mov    -0x28(%rbp),%rax
shl    $0x20,%rax
mov    %rax,-0x40(%rbp)
movslq -0xc(%rbp),%rax
mov    %rax,-0x38(%rbp)
mov    -0x38(%rbp),%rax
or     -0x40(%rbp),%rax
mov    %rax,-0x30(%rbp)
mov    -0x44(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x44(%rbp)
jmp    1125 <logical+0x15>
mov    -0x28(%rbp),%rax
cmp    -0x30(%rbp),%rax
jne    1197 <logical+0x87>
lea    0xe6e(%rip),%rdi
call   1030 <printf@plt>
mov    -0xc(%rbp),%eax
add    $0x50,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<logical>:
push   %rbx
mov    %edi,%ebx
and    %esi,%ebx
movslq %ebx,%rax
mov    %rax,%rcx
shl    $0x20,%rcx
not    %rax
test   %rcx,%rax
jne    1133 <logical+0x23>
lea    0xed2(%rip),%rdi
call   1030 <puts@plt>
mov    %ebx,%eax
pop    %rbx
ret

LLVM IR (-O0):
@.str = [24 x i8] c"cc and dd is the same!\0A\00"
define i32 @logical(i32 %0, i32 %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca i32
%10 = alloca i32
%11 = alloca i64
%12 = alloca i64
%13 = alloca i64
%14 = alloca i64
%15 = alloca i32
store i32 %0, i32* %3
store i32 %1, i32* %4
store i32 0, i32* %15
br label %16
16: ; preds = %34, %2
%17 = load i32, i32* %15
%18 = icmp slt i32 %17, 5010
br i1 %18, label %19, label %37
19: ; preds = %16
%20 = load i32, i32* %3
%21 = load i32, i32* %4
%22 = and i32 %20, %21
store i32 %22, i32* %5
%23 = load i32, i32* %5
%24 = sext i32 %23 to i64
store i64 %24, i64* %11
%25 = load i64, i64* %11
%26 = lshr i64 %25, 32
store i64 %26, i64* %13
%27 = load i64, i64* %11
%28 = shl i64 %27, 32
store i64 %28, i64* %14
%29 = load i32, i32* %5
%30 = sext i32 %29 to i64
store i64 %30, i64* %13
%31 = load i64, i64* %13
%32 = load i64, i64* %14
%33 = or i64 %31, %32
store i64 %33, i64* %12
br label %34
34: ; preds = %19
%35 = load i32, i32* %15
%36 = add nsw i32 %35, 1
store i32 %36, i32* %15
br label %16
37: ; preds = %16
%38 = load i64, i64* %11
%39 = load i64, i64* %12
%40 = icmp eq i64 %38, %39
br i1 %40, label %41, label %43
41: ; preds = %37
%42 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str, i64 0, i64 0))
br label %43
43: ; preds = %41, %37
%44 = load i32, i32* %5
ret i32 %44
}

LLVM IR (-O2):
@str = [23 x i8] c"cc and dd is the same!\00"
define i32 @logical(i32 %0, i32 %1) {
%3 = and i32 %1, %0
%4 = sext i32 %3 to i64
%5 = shl nsw i64 %4, 32
%6 = or i64 %5, %4
%7 = icmp eq i64 %6, %4
br i1 %7, label %8, label %10
8: ; preds = %2
%9 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([23 x i8], [23 x i8]* @str, i64 0, i64 0))
br label %10
10: ; preds = %8, %2
ret i32 %3
}