#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*/ static_assert(int);
scalar_t__ unknown1();
int main(int flag) {
  int j = 2;
  int k = 0;
  while (unknown1()) {
    if (flag)
      j = j + 4;
    else {
      j = j + 2;
      k = k + 1;
    }
  }
  if (k != 0)
    static_assert(j == 2 * k + 2);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
movl   $0x2,-0xc(%rbp)
movl   $0x0,-0x10(%rbp)
mov    $0x0,%al
call   1030 <unknown1@plt>
cmp    $0x0,%rax
je     1180 <main+0x60>
cmpl   $0x0,-0x8(%rbp)
je     1169 <main+0x49>
mov    -0xc(%rbp),%eax
add    $0x4,%eax
mov    %eax,-0xc(%rbp)
jmp    117b <main+0x5b>
mov    -0xc(%rbp),%eax
add    $0x2,%eax
mov    %eax,-0xc(%rbp)
mov    -0x10(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x10(%rbp)
jmp    1140 <main+0x20>
cmpl   $0x0,-0x10(%rbp)
je     11a5 <main+0x85>
mov    -0xc(%rbp),%eax
mov    -0x10(%rbp),%ecx
shl    $0x1,%ecx
add    $0x2,%ecx
cmp    %ecx,%eax
sete   %al
and    $0x1,%al
movzbl %al,%edi
call   1040 <static_assert@plt>
mov    -0x4(%rbp),%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %edi,%ebp
xor    %eax,%eax
call   1030 <unknown1@plt>
test   %rax,%rax
je     1187 <main+0x67>
xor    %r14d,%r14d
xor    %eax,%eax
test   %ebp,%ebp
sete   %r14b
setne  %al
lea    (%rax,%rax,1),%r15d
add    $0x2,%r15d
lea    (%r14,%r14,1),%r12d
mov    $0x2,%r13d
xor    %ebp,%ebp
mov    $0x2,%ebx
add    %r12d,%r13d
add    %r15d,%ebx
add    %r14d,%ebp
xor    %eax,%eax
call   1030 <unknown1@plt>
test   %rax,%rax
jne    1160 <main+0x40>
test   %ebp,%ebp
je     1187 <main+0x67>
xor    %edi,%edi
cmp    %r13d,%ebx
sete   %dil
call   1040 <static_assert@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
define i32 @main(i32 %0) {
%2 = alloca i32
%3 = alloca i32
%4 = alloca i32
%5 = alloca i32
store i32 0, i32* %2
store i32 %0, i32* %3
store i32 2, i32* %4
store i32 0, i32* %5
br label %6
6: ; preds = %20, %1
%7 = call i64 (...) @unknown1()
%8 = icmp ne i64 %7, 0
br i1 %8, label %9, label %21
9: ; preds = %6
%10 = load i32, i32* %3
%11 = icmp ne i32 %10, 0
br i1 %11, label %12, label %15
12: ; preds = %9
%13 = load i32, i32* %4
%14 = add nsw i32 %13, 4
store i32 %14, i32* %4
br label %20
15: ; preds = %9
%16 = load i32, i32* %4
%17 = add nsw i32 %16, 2
store i32 %17, i32* %4
%18 = load i32, i32* %5
%19 = add nsw i32 %18, 1
store i32 %19, i32* %5
br label %20
20: ; preds = %15, %12
br label %6
21: ; preds = %6
%22 = load i32, i32* %5
%23 = icmp ne i32 %22, 0
br i1 %23, label %24, label %32
24: ; preds = %21
%25 = load i32, i32* %4
%26 = load i32, i32* %5
%27 = mul nsw i32 2, %26
%28 = add nsw i32 %27, 2
%29 = icmp eq i32 %25, %28
%30 = zext i1 %29 to i32
%31 = call i32 @static_assert(i32 %30)
br label %32
32: ; preds = %24, %21
%33 = load i32, i32* %2
ret i32 %33
}

LLVM IR (-O2):
define i32 @main(i32 %0) {
%2 = tail call i64 (...) @unknown1()
%3 = icmp eq i64 %2, 0
br i1 %3, label %23, label %4
4: ; preds = %1
%5 = icmp eq i32 %0, 0
%6 = select i1 %5, i32 2, i32 4
%7 = zext i1 %5 to i32
br label %8
8: ; preds = %4, %8
%9 = phi i32 [ 0, %4 ], [ %12, %8 ]
%10 = phi i32 [ 2, %4 ], [ %11, %8 ]
%11 = add nuw nsw i32 %10, %6
%12 = add nuw nsw i32 %9, %7
%13 = tail call i64 (...) @unknown1()
%14 = icmp eq i64 %13, 0
br i1 %14, label %15, label %8
15: ; preds = %8
%16 = icmp eq i32 %12, 0
br i1 %16, label %23, label %17
17: ; preds = %15
%18 = shl nuw nsw i32 %12, 1
%19 = add nuw nsw i32 %18, 2
%20 = icmp eq i32 %11, %19
%21 = zext i1 %20 to i32
%22 = tail call i32 @static_assert(i32 %21)
br label %23
23: ; preds = %1, %17, %15
ret i32 0
}