#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*/ assert(int);
int test(void) {
  int flags = 0;
  (flags = ((flags - (!!(flags & (1))) * (1)) + (!!1) * (1)));
  assert((!!(flags & (1))) == 1);
  assert((!!(flags & (2))) == 0);
  assert((!!(flags & (4))) == 0);
  (flags = ((flags - (!!(flags & (1))) * (1)) + (!!0) * (1)));
  assert((!!(flags & (1))) == 0);
  assert((!!(flags & (2))) == 0);
  assert((!!(flags & (4))) == 0);
  (flags = ((flags - (!!(flags & (4))) * (4)) + (!!1) * (4)));
  (flags = ((flags - (!!(flags & (2))) * (2)) + (!!1) * (2)));
  assert((!!(flags & (1))) == 0);
  assert((!!(flags & (2))) == 1);
  assert((!!(flags & (4))) == 1);
  (flags = ((flags - (!!(flags & (2))) * (2)) + (!!0) * (2)));
  assert((!!(flags & (1))) == 0);
  assert((!!(flags & (2))) == 0);
  assert((!!(flags & (4))) == 1);
}


x86 assembly (clang, -O0):
<test>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
and    $0x1,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%ecx
shl    $0x0,%ecx
sub    %ecx,%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
and    $0x1,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%ecx
shl    $0x0,%ecx
sub    %ecx,%eax
add    $0x0,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
and    $0x4,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%ecx
shl    $0x2,%ecx
sub    %ecx,%eax
add    $0x4,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
and    $0x2,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%ecx
shl    $0x1,%ecx
sub    %ecx,%eax
add    $0x2,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
mov    -0x8(%rbp),%ecx
and    $0x2,%ecx
cmp    $0x0,%ecx
setne  %cl
xor    $0xff,%cl
xor    $0xff,%cl
and    $0x1,%cl
movzbl %cl,%ecx
shl    $0x1,%ecx
sub    %ecx,%eax
add    $0x0,%eax
mov    %eax,-0x8(%rbp)
mov    -0x8(%rbp),%eax
and    $0x1,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
and    $0x2,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x0,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x8(%rbp),%eax
and    $0x4,%eax
cmp    $0x0,%eax
setne  %al
xor    $0xff,%al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
cmp    $0x1,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1030 <assert@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test>:
push   %rax
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
call   1030 <assert@plt>
mov    $0x1,%edi
pop    %rax
jmp    1030 <assert@plt>

LLVM IR (-O0):
define i32 @test() {
%1 = alloca i32
%2 = alloca i32
store i32 0, i32* %2
%3 = load i32, i32* %2
%4 = load i32, i32* %2
%5 = and i32 %4, 1
%6 = icmp ne i32 %5, 0
%7 = xor i1 %6, true
%8 = xor i1 %7, true
%9 = zext i1 %8 to i32
%10 = mul nsw i32 %9, 1
%11 = sub nsw i32 %3, %10
%12 = add nsw i32 %11, 1
store i32 %12, i32* %2
%13 = load i32, i32* %2
%14 = and i32 %13, 1
%15 = icmp ne i32 %14, 0
%16 = xor i1 %15, true
%17 = xor i1 %16, true
%18 = zext i1 %17 to i32
%19 = icmp eq i32 %18, 1
%20 = zext i1 %19 to i32
%21 = call i32 @assert(i32 %20)
%22 = load i32, i32* %2
%23 = and i32 %22, 2
%24 = icmp ne i32 %23, 0
%25 = xor i1 %24, true
%26 = xor i1 %25, true
%27 = zext i1 %26 to i32
%28 = icmp eq i32 %27, 0
%29 = zext i1 %28 to i32
%30 = call i32 @assert(i32 %29)
%31 = load i32, i32* %2
%32 = and i32 %31, 4
%33 = icmp ne i32 %32, 0
%34 = xor i1 %33, true
%35 = xor i1 %34, true
%36 = zext i1 %35 to i32
%37 = icmp eq i32 %36, 0
%38 = zext i1 %37 to i32
%39 = call i32 @assert(i32 %38)
%40 = load i32, i32* %2
%41 = load i32, i32* %2
%42 = and i32 %41, 1
%43 = icmp ne i32 %42, 0
%44 = xor i1 %43, true
%45 = xor i1 %44, true
%46 = zext i1 %45 to i32
%47 = mul nsw i32 %46, 1
%48 = sub nsw i32 %40, %47
%49 = add nsw i32 %48, 0
store i32 %49, i32* %2
%50 = load i32, i32* %2
%51 = and i32 %50, 1
%52 = icmp ne i32 %51, 0
%53 = xor i1 %52, true
%54 = xor i1 %53, true
%55 = zext i1 %54 to i32
%56 = icmp eq i32 %55, 0
%57 = zext i1 %56 to i32
%58 = call i32 @assert(i32 %57)
%59 = load i32, i32* %2
%60 = and i32 %59, 2
%61 = icmp ne i32 %60, 0
%62 = xor i1 %61, true
%63 = xor i1 %62, true
%64 = zext i1 %63 to i32
%65 = icmp eq i32 %64, 0
%66 = zext i1 %65 to i32
%67 = call i32 @assert(i32 %66)
%68 = load i32, i32* %2
%69 = and i32 %68, 4
%70 = icmp ne i32 %69, 0
%71 = xor i1 %70, true
%72 = xor i1 %71, true
%73 = zext i1 %72 to i32
%74 = icmp eq i32 %73, 0
%75 = zext i1 %74 to i32
%76 = call i32 @assert(i32 %75)
%77 = load i32, i32* %2
%78 = load i32, i32* %2
%79 = and i32 %78, 4
%80 = icmp ne i32 %79, 0
%81 = xor i1 %80, true
%82 = xor i1 %81, true
%83 = zext i1 %82 to i32
%84 = mul nsw i32 %83, 4
%85 = sub nsw i32 %77, %84
%86 = add nsw i32 %85, 4
store i32 %86, i32* %2
%87 = load i32, i32* %2
%88 = load i32, i32* %2
%89 = and i32 %88, 2
%90 = icmp ne i32 %89, 0
%91 = xor i1 %90, true
%92 = xor i1 %91, true
%93 = zext i1 %92 to i32
%94 = mul nsw i32 %93, 2
%95 = sub nsw i32 %87, %94
%96 = add nsw i32 %95, 2
store i32 %96, i32* %2
%97 = load i32, i32* %2
%98 = and i32 %97, 1
%99 = icmp ne i32 %98, 0
%100 = xor i1 %99, true
%101 = xor i1 %100, true
%102 = zext i1 %101 to i32
%103 = icmp eq i32 %102, 0
%104 = zext i1 %103 to i32
%105 = call i32 @assert(i32 %104)
%106 = load i32, i32* %2
%107 = and i32 %106, 2
%108 = icmp ne i32 %107, 0
%109 = xor i1 %108, true
%110 = xor i1 %109, true
%111 = zext i1 %110 to i32
%112 = icmp eq i32 %111, 1
%113 = zext i1 %112 to i32
%114 = call i32 @assert(i32 %113)
%115 = load i32, i32* %2
%116 = and i32 %115, 4
%117 = icmp ne i32 %116, 0
%118 = xor i1 %117, true
%119 = xor i1 %118, true
%120 = zext i1 %119 to i32
%121 = icmp eq i32 %120, 1
%122 = zext i1 %121 to i32
%123 = call i32 @assert(i32 %122)
%124 = load i32, i32* %2
%125 = load i32, i32* %2
%126 = and i32 %125, 2
%127 = icmp ne i32 %126, 0
%128 = xor i1 %127, true
%129 = xor i1 %128, true
%130 = zext i1 %129 to i32
%131 = mul nsw i32 %130, 2
%132 = sub nsw i32 %124, %131
%133 = add nsw i32 %132, 0
store i32 %133, i32* %2
%134 = load i32, i32* %2
%135 = and i32 %134, 1
%136 = icmp ne i32 %135, 0
%137 = xor i1 %136, true
%138 = xor i1 %137, true
%139 = zext i1 %138 to i32
%140 = icmp eq i32 %139, 0
%141 = zext i1 %140 to i32
%142 = call i32 @assert(i32 %141)
%143 = load i32, i32* %2
%144 = and i32 %143, 2
%145 = icmp ne i32 %144, 0
%146 = xor i1 %145, true
%147 = xor i1 %146, true
%148 = zext i1 %147 to i32
%149 = icmp eq i32 %148, 0
%150 = zext i1 %149 to i32
%151 = call i32 @assert(i32 %150)
%152 = load i32, i32* %2
%153 = and i32 %152, 4
%154 = icmp ne i32 %153, 0
%155 = xor i1 %154, true
%156 = xor i1 %155, true
%157 = zext i1 %156 to i32
%158 = icmp eq i32 %157, 1
%159 = zext i1 %158 to i32
%160 = call i32 @assert(i32 %159)
%161 = load i32, i32* %1
ret i32 %161
}

LLVM IR (-O2):
define i32 @test() {
%1 = tail call i32 @assert(i32 1)
%2 = tail call i32 @assert(i32 1)
%3 = tail call i32 @assert(i32 1)
%4 = tail call i32 @assert(i32 1)
%5 = tail call i32 @assert(i32 1)
%6 = tail call i32 @assert(i32 1)
%7 = tail call i32 @assert(i32 1)
%8 = tail call i32 @assert(i32 1)
%9 = tail call i32 @assert(i32 1)
%10 = tail call i32 @assert(i32 1)
%11 = tail call i32 @assert(i32 1)
%12 = tail call i32 @assert(i32 1)
ret i32 undef
}