#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 *, void *);
int main() {
  void *ptr = (void *)0x1;
  while ((ptr = (void *)((long long)ptr << 0x1)))
    printf("\r!0x%p does not hold", ptr);
  printf("\n!0x%p holds\n", ptr);
  ptr = (void *)0x1;
  while ((ptr = (void *)((long long)ptr << 0x1)) != NULL)
    printf("\r(0x%p != NULL) does not hold", ptr);
  printf("\n(0x%p != NULL) holds\n", ptr);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
movl   $0x0,-0x4(%rbp)
mov    $0x1,%eax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1153 <main+0x43>
mov    -0x10(%rbp),%rsi
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
jmp    1128 <main+0x18>
mov    -0x10(%rbp),%rsi
lea    0xeb7(%rip),%rdi
call   1030 <printf@plt>
mov    $0x1,%eax
mov    %rax,-0x10(%rbp)
mov    -0x10(%rbp),%rax
shl    $0x1,%rax
mov    %rax,-0x10(%rbp)
cmp    $0x0,%rax
je     1197 <main+0x87>
mov    -0x10(%rbp),%rsi
lea    0xe96(%rip),%rdi
call   1030 <printf@plt>
jmp    116c <main+0x5c>
mov    -0x10(%rbp),%rsi
lea    0xe9f(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %r14
push   %rbx
push   %rax
mov    $0x2,%ebx
lea    0xee0(%rip),%r14
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
add    %rbx,%rbx
jne    1120 <main+0x10>
lea    0xede(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
mov    $0x2,%ebx
lea    0xed9(%rip),%r14
nopw   0x0(%rax,%rax,1)
mov    %r14,%rdi
mov    %rbx,%rsi
call   1030 <printf@plt>
add    %rbx,%rbx
jne    1150 <main+0x40>
lea    0xeda(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %r14
ret

LLVM IR (-O0):
@.str = [21 x i8] c"\0D!0x%p does not hold\00"
@.str.1 = [14 x i8] c"\0A!0x%p holds\0A\00"
@.str.2 = [30 x i8] c"\0D(0x%p != NULL) does not hold\00"
@.str.3 = [23 x i8] c"\0A(0x%p != NULL) holds\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i8*
store i32 0, i32* %1
store i8* inttoptr (i64 1 to i8*), i8** %2
br label %3
3: ; preds = %9, %0
%4 = load i8*, i8** %2
%5 = ptrtoint i8* %4 to i64
%6 = shl i64 %5, 1
%7 = inttoptr i64 %6 to i8*
store i8* %7, i8** %2
%8 = icmp ne i8* %7, null
br i1 %8, label %9, label %12
9: ; preds = %3
%10 = load i8*, i8** %2
%11 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %10)
br label %3
12: ; preds = %3
%13 = load i8*, i8** %2
%14 = call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* %13)
store i8* inttoptr (i64 1 to i8*), i8** %2
br label %15
15: ; preds = %21, %12
%16 = load i8*, i8** %2
%17 = ptrtoint i8* %16 to i64
%18 = shl i64 %17, 1
%19 = inttoptr i64 %18 to i8*
store i8* %19, i8** %2
%20 = icmp ne i8* %19, null
br i1 %20, label %21, label %24
21: ; preds = %15
%22 = load i8*, i8** %2
%23 = call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %22)
br label %15
24: ; preds = %15
%25 = load i8*, i8** %2
%26 = call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* %25)
ret i32 0
}

LLVM IR (-O2):
@.str = [21 x i8] c"\0D!0x%p does not hold\00"
@.str.1 = [14 x i8] c"\0A!0x%p holds\0A\00"
@.str.2 = [30 x i8] c"\0D(0x%p != NULL) does not hold\00"
@.str.3 = [23 x i8] c"\0A(0x%p != NULL) holds\0A\00"
define i32 @main() {
br label %1
1: ; preds = %0, %1
%2 = phi i8* [ inttoptr (i64 2 to i8*), %0 ], [ %6, %1 ]
%3 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str, i64 0, i64 0), i8* %2)
%4 = ptrtoint i8* %2 to i64
%5 = shl i64 %4, 1
%6 = inttoptr i64 %5 to i8*
%7 = icmp eq i64 %5, 0
br i1 %7, label %8, label %1
8: ; preds = %1
%9 = tail call i32 @printf(i8* getelementptr inbounds ([14 x i8], [14 x i8]* @.str.1, i64 0, i64 0), i8* null)
br label %10
10: ; preds = %8, %10
%11 = phi i8* [ inttoptr (i64 2 to i8*), %8 ], [ %15, %10 ]
%12 = tail call i32 @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.2, i64 0, i64 0), i8* %11)
%13 = ptrtoint i8* %11 to i64
%14 = shl i64 %13, 1
%15 = inttoptr i64 %14 to i8*
%16 = icmp eq i64 %14, 0
br i1 %16, label %17, label %10
17: ; preds = %10
%18 = tail call i32 @printf(i8* getelementptr inbounds ([23 x i8], [23 x i8]* @.str.3, i64 0, i64 0), i8* null)
ret i32 0
}