#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 */
char *getenv(char *);
void test_loop() {
  char *spec;
  char *block_size;
  spec = getenv("BLOCK");
  while ((!spec && !(spec = getenv("BLOCK_SIZE")) &&
          !(spec = getenv("BLOCKSIZE")))) {
    block_size = 0;
  }
}


x86 assembly (clang, -O0):
<test_loop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
lea    0xee1(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
xor    %eax,%eax
cmpq   $0x0,-0x8(%rbp)
mov    %al,-0x11(%rbp)
jne    1176 <test_loop+0x66>
lea    0xec7(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,%rcx
mov    %rcx,-0x8(%rbp)
xor    %eax,%eax
cmp    $0x0,%rcx
mov    %al,-0x11(%rbp)
jne    1176 <test_loop+0x66>
lea    0xeb0(%rip),%rdi
call   1030 <getenv@plt>
mov    %rax,-0x8(%rbp)
cmp    $0x0,%rax
setne  %al
xor    $0xff,%al
mov    %al,-0x11(%rbp)
mov    -0x11(%rbp),%al
test   $0x1,%al
jne    1186 <test_loop+0x76>
jmp    1193 <test_loop+0x83>
movq   $0x0,-0x10(%rbp)
jmp    1128 <test_loop+0x18>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<test_loop>:
push   %rax
lea    0xee8(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    1144 <test_loop+0x34>
lea    0xedd(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
jne    1144 <test_loop+0x34>
lea    0xed7(%rip),%rdi
call   1030 <getenv@plt>
test   %rax,%rax
je     1150 <test_loop+0x40>
pop    %rax
ret
cs nopw 0x0(%rax,%rax,1)
jmp    1150 <test_loop+0x40>

LLVM IR (-O0):
@.str = [6 x i8] c"BLOCK\00"
@.str.1 = [11 x i8] c"BLOCK_SIZE\00"
@.str.2 = [10 x i8] c"BLOCKSIZE\00"
define void @test_loop() {
%1 = alloca i8*
%2 = alloca i8*
%3 = call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
store i8* %3, i8** %1
br label %4
4: ; preds = %16, %0
%5 = load i8*, i8** %1
%6 = icmp ne i8* %5, null
br i1 %6, label %14, label %7
7: ; preds = %4
%8 = call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
store i8* %8, i8** %1
%9 = icmp ne i8* %8, null
br i1 %9, label %14, label %10
10: ; preds = %7
%11 = call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
store i8* %11, i8** %1
%12 = icmp ne i8* %11, null
%13 = xor i1 %12, true
br label %14
14: ; preds = %10, %7, %4
%15 = phi i1 [ false, %7 ], [ false, %4 ], [ %13, %10 ]
br i1 %15, label %16, label %17
16: ; preds = %14
store i8* null, i8** %2
br label %4
17: ; preds = %14
ret void
}

LLVM IR (-O2):
@.str = [6 x i8] c"BLOCK\00"
@.str.1 = [11 x i8] c"BLOCK_SIZE\00"
@.str.2 = [10 x i8] c"BLOCKSIZE\00"
define void @test_loop() {
%1 = tail call i8* @getenv(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str, i64 0, i64 0))
%2 = icmp eq i8* %1, null
br i1 %2, label %3, label %10
3: ; preds = %0
%4 = tail call i8* @getenv(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0))
%5 = icmp eq i8* %4, null
br i1 %5, label %6, label %10
6: ; preds = %3
%7 = tail call i8* @getenv(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str.2, i64 0, i64 0))
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %10
9: ; preds = %6, %9
br label %9
10: ; preds = %3, %6, %0
ret void
}