#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 and_i16(int, int);
int and_i32(int, int);
int and_i64(int, int);
int and_i8(int, int);
int fail(int /*<<< orphan*/);
int test_and(void) {
  if (and_i8(0x5a, 0x0f) != 0xa)
    return fail(0);
  if (and_i16(0x5abc, 0xf000) != 0x5000)
    return fail(0);
  if (and_i32(0x5abc1234, 0x0f000000) != 0x0a000000)
    return fail(0);
  if (and_i64(0x5abc123456781234LL, 0x0f000000) != 0x06000000)
    return fail(0);
  return 0x40000;
}


x86 assembly (clang, -O0):
<test_and>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
mov    $0x5a,%edi
mov    $0xf,%esi
call   1070 <and_i8@plt>
cmp    $0xa,%eax
je     117f <test_and+0x2f>
xor    %edi,%edi
call   1030 <fail@plt>
mov    %eax,-0x4(%rbp)
jmp    1201 <test_and+0xb1>
mov    $0x5abc,%edi
mov    $0xf000,%esi
call   1040 <and_i16@plt>
cmp    $0x5000,%eax
je     11a8 <test_and+0x58>
xor    %edi,%edi
call   1030 <fail@plt>
mov    %eax,-0x4(%rbp)
jmp    1201 <test_and+0xb1>
mov    $0x5abc1234,%edi
mov    $0xf000000,%esi
call   1060 <and_i32@plt>
cmp    $0xa000000,%eax
je     11d1 <test_and+0x81>
xor    %edi,%edi
call   1030 <fail@plt>
mov    %eax,-0x4(%rbp)
jmp    1201 <test_and+0xb1>
mov    $0x56781234,%edi
mov    $0xf000000,%esi
call   1050 <and_i64@plt>
cmp    $0x6000000,%eax
je     11fa <test_and+0xaa>
xor    %edi,%edi
call   1030 <fail@plt>
mov    %eax,-0x4(%rbp)
jmp    1201 <test_and+0xb1>
movl   $0x40000,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_and>:
push   %rax
mov    $0x5a,%edi
mov    $0xf,%esi
call   1070 <and_i8@plt>
cmp    $0xa,%eax
jne    11ae <test_and+0x5e>
mov    $0x5abc,%edi
mov    $0xf000,%esi
call   1040 <and_i16@plt>
cmp    $0x5000,%eax
jne    11ae <test_and+0x5e>
mov    $0x5abc1234,%edi
mov    $0xf000000,%esi
call   1060 <and_i32@plt>
cmp    $0xa000000,%eax
jne    11ae <test_and+0x5e>
mov    $0x56781234,%edi
mov    $0xf000000,%esi
call   1050 <and_i64@plt>
cmp    $0x6000000,%eax
jne    11ae <test_and+0x5e>
mov    $0x40000,%eax
pop    %rcx
ret
xor    %edi,%edi
pop    %rax
jmp    1030 <fail@plt>

LLVM IR (-O0):
define i32 @test_and() {
%1 = alloca i32
%2 = call i32 @and_i8(i32 90, i32 15)
%3 = icmp ne i32 %2, 10
br i1 %3, label %4, label %6
4: ; preds = %0
%5 = call i32 @fail(i32 0)
store i32 %5, i32* %1
br label %22
6: ; preds = %0
%7 = call i32 @and_i16(i32 23228, i32 61440)
%8 = icmp ne i32 %7, 20480
br i1 %8, label %9, label %11
9: ; preds = %6
%10 = call i32 @fail(i32 0)
store i32 %10, i32* %1
br label %22
11: ; preds = %6
%12 = call i32 @and_i32(i32 1522274868, i32 251658240)
%13 = icmp ne i32 %12, 167772160
br i1 %13, label %14, label %16
14: ; preds = %11
%15 = call i32 @fail(i32 0)
store i32 %15, i32* %1
br label %22
16: ; preds = %11
%17 = call i32 @and_i64(i32 1450709556, i32 251658240)
%18 = icmp ne i32 %17, 100663296
br i1 %18, label %19, label %21
19: ; preds = %16
%20 = call i32 @fail(i32 0)
store i32 %20, i32* %1
br label %22
21: ; preds = %16
store i32 262144, i32* %1
br label %22
22: ; preds = %21, %19, %14, %9, %4
%23 = load i32, i32* %1
ret i32 %23
}

LLVM IR (-O2):
define i32 @test_and() {
%1 = tail call i32 @and_i8(i32 90, i32 15)
%2 = icmp eq i32 %1, 10
br i1 %2, label %3, label %12
3: ; preds = %0
%4 = tail call i32 @and_i16(i32 23228, i32 61440)
%5 = icmp eq i32 %4, 20480
br i1 %5, label %6, label %12
6: ; preds = %3
%7 = tail call i32 @and_i32(i32 1522274868, i32 251658240)
%8 = icmp eq i32 %7, 167772160
br i1 %8, label %9, label %12
9: ; preds = %6
%10 = tail call i32 @and_i64(i32 1450709556, i32 251658240)
%11 = icmp eq i32 %10, 100663296
br i1 %11, label %14, label %12
12: ; preds = %9, %6, %3, %0
%13 = tail call i32 @fail(i32 0)
br label %14
14: ; preds = %12, %9
%15 = phi i32 [ 262144, %9 ], [ %13, %12 ]
ret i32 %15
}