#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 *, ...);
int tilde_zero();
void tilde_usage() {
  printf("Hello tilde test\n");
  int k = 0;
  printf("k no tilde %i\n", k);
  printf("k with tilde %i\n", ~k);
  printf("~32767: %i\n", ~32767);
  printf("(size + 32767) & ~32767: %i\n", ~32767);
  printf("(50 + 32767) & ~32767: %i\n", (50 + 32767) & ~32767);
  printf("(32767 + 32767) & ~32767: %i\n", (32767 + 32767) & ~32767);
  printf("(32768 + 32767) & ~32767: %i\n", (32768 + 32767) & ~32767);
  printf("(32769 + 32767) & ~32767: %i\n", (32769 + 32767) & ~32767);
  printf("(-1 + 32767) & ~32767: %i\n", (-1 + 32767) & ~32767);
  printf("(10032434 + 32767) & ~32767: %i\n", (10032434 + 32767) & ~32767);
  printf("return unsigned via ~0: %i\n", tilde_zero());
}


x86 assembly (clang, -O0):
<tilde_usage>:
push   %rbp
mov    %rsp,%rbp
sub    $0x10,%rsp
lea    0xed1(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%esi
lea    0xecb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x4(%rbp),%esi
xor    $0xffffffff,%esi
lea    0xec6(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef5(%rip),%rdi
mov    $0xffff8000,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xeb6(%rip),%rdi
mov    $0xffff8000,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec0(%rip),%rdi
mov    $0x8000,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xec8(%rip),%rdi
mov    $0x8000,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xed3(%rip),%rdi
mov    $0x8000,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xede(%rip),%rdi
mov    $0x10000,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xee9(%rip),%rdi
xor    %esi,%esi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xef4(%rip),%rdi
mov    $0x998000,%esi
mov    $0x0,%al
call   1040 <printf@plt>
mov    $0x0,%al
call   1030 <tilde_zero@plt>
mov    %eax,%esi
lea    0xef9(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
add    $0x10,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<tilde_usage>:
push   %rax
lea    0xfd2(%rip),%rdi
call   1030 <puts@plt>
lea    0xebc(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xebb(%rip),%rdi
mov    $0xffffffff,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xee5(%rip),%rdi
mov    $0xffff8000,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xea6(%rip),%rdi
mov    $0xffff8000,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb0(%rip),%rdi
mov    $0x8000,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xeb8(%rip),%rdi
mov    $0x8000,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xec3(%rip),%rdi
mov    $0x8000,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xece(%rip),%rdi
mov    $0x10000,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xed9(%rip),%rdi
xor    %esi,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xee4(%rip),%rdi
mov    $0x998000,%esi
xor    %eax,%eax
call   1050 <printf@plt>
xor    %eax,%eax
call   1040 <tilde_zero@plt>
lea    0xeeb(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
pop    %rcx
jmp    1050 <printf@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Hello tilde test\0A\00"
@.str.1 = [15 x i8] c"k no tilde %i\0A\00"
@.str.2 = [17 x i8] c"k with tilde %i\0A\00"
@.str.3 = [12 x i8] c"~32767: %i\0A\00"
@.str.4 = [29 x i8] c"(size + 32767) & ~32767: %i\0A\00"
@.str.5 = [27 x i8] c"(50 + 32767) & ~32767: %i\0A\00"
@.str.6 = [30 x i8] c"(32767 + 32767) & ~32767: %i\0A\00"
@.str.7 = [30 x i8] c"(32768 + 32767) & ~32767: %i\0A\00"
@.str.8 = [30 x i8] c"(32769 + 32767) & ~32767: %i\0A\00"
@.str.9 = [27 x i8] c"(-1 + 32767) & ~32767: %i\0A\00"
@.str.10 = [33 x i8] c"(10032434 + 32767) & ~32767: %i\0A\00"
@.str.11 = [28 x i8] c"return unsigned via ~0: %i\0A\00"
define void @tilde_usage() {
%1 = alloca i32
%2 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
store i32 0, i32* %1
%3 = load i32, i32* %1
%4 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 %3)
%5 = load i32, i32* %1
%6 = xor i32 %5, -1
%7 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 %6)
%8 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 -32768)
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 -32768)
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 32768)
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 32768)
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 32768)
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i32 65536)
%14 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i32 0)
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 10059776)
%16 = call i32 (...) @tilde_zero()
%17 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), i32 %16)
ret void
}

LLVM IR (-O2):
@.str.1 = [15 x i8] c"k no tilde %i\0A\00"
@.str.2 = [17 x i8] c"k with tilde %i\0A\00"
@.str.3 = [12 x i8] c"~32767: %i\0A\00"
@.str.4 = [29 x i8] c"(size + 32767) & ~32767: %i\0A\00"
@.str.5 = [27 x i8] c"(50 + 32767) & ~32767: %i\0A\00"
@.str.6 = [30 x i8] c"(32767 + 32767) & ~32767: %i\0A\00"
@.str.7 = [30 x i8] c"(32768 + 32767) & ~32767: %i\0A\00"
@.str.8 = [30 x i8] c"(32769 + 32767) & ~32767: %i\0A\00"
@.str.9 = [27 x i8] c"(-1 + 32767) & ~32767: %i\0A\00"
@.str.10 = [33 x i8] c"(10032434 + 32767) & ~32767: %i\0A\00"
@.str.11 = [28 x i8] c"return unsigned via ~0: %i\0A\00"
@str = [17 x i8] c"Hello tilde test\00"
define void @tilde_usage() {
%1 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @str, i64 0, i64 0))
%2 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.1, i64 0, i64 0), i32 0)
%3 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.2, i64 0, i64 0), i32 -1)
%4 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i32 -32768)
%5 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([29 x i8], [29 x i8]* @.str.4, i64 0, i64 0), i32 -32768)
%6 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.5, i64 0, i64 0), i32 32768)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.6, i64 0, i64 0), i32 32768)
%8 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.7, i64 0, i64 0), i32 32768)
%9 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([30 x i8], [30 x i8]* @.str.8, i64 0, i64 0), i32 65536)
%10 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([27 x i8], [27 x i8]* @.str.9, i64 0, i64 0), i32 0)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([33 x i8], [33 x i8]* @.str.10, i64 0, i64 0), i32 10059776)
%12 = tail call i32 (...) @tilde_zero()
%13 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @.str.11, i64 0, i64 0), i32 %12)
ret void
}