#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 */
scalar_t__ atoi(char *);
int /*<<< orphan*/ printf(char *, unsigned int);
int main(int argc, char *argv[]) {
  unsigned int x = (unsigned int)atoi(argv[1]);
  unsigned int y = ~x;
  printf("x = [%u]\n", x);
  printf("~x = [%u]\n", y);
  printf("x | ~x = [%u]\n", x | y);
  printf("x & ~x = [%u]\n", x & y);
  printf("(~x | 1) & x = [%u]\n", (~x | 1) & x);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
call   1040 <atoi@plt>
mov    %eax,-0x14(%rbp)
mov    -0x14(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x18(%rbp)
mov    -0x14(%rbp),%esi
lea    0xed0(%rip),%rdi
call   1030 <printf@plt>
mov    -0x18(%rbp),%esi
lea    0xeab(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
or     -0x18(%rbp),%esi
lea    0xe86(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
and    -0x18(%rbp),%esi
lea    0xe83(%rip),%rdi
call   1030 <printf@plt>
mov    -0x14(%rbp),%esi
xor    $0xffffffff,%esi
or     $0x1,%esi
and    -0x14(%rbp),%esi
lea    0xe7a(%rip),%rdi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %rbx
push   %rax
mov    0x8(%rsi),%rdi
call   1040 <atoi@plt>
mov    %rax,%rbx
mov    %ebx,%ebp
not    %ebp
lea    0xeef(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
lea    0xecb(%rip),%rdi
mov    %ebp,%esi
call   1030 <printf@plt>
lea    0xeaa(%rip),%rdi
mov    $0xffffffff,%esi
call   1030 <printf@plt>
lea    0xea8(%rip),%rdi
xor    %esi,%esi
call   1030 <printf@plt>
and    $0x1,%ebx
lea    0xea6(%rip),%rdi
mov    %ebx,%esi
call   1030 <printf@plt>
xor    %eax,%eax
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret

LLVM IR (-O0):
@.str = [10 x i8] c"x = [%u]\0A\00"
@.str.1 = [11 x i8] c"~x = [%u]\0A\00"
@.str.2 = [15 x i8] c"x | ~x = [%u]\0A\00"
@.str.3 = [15 x i8] c"x & ~x = [%u]\0A\00"
@.str.4 = [21 x i8] c"(~x | 1) & x = [%u]\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = load i8**, i8*** %5
%9 = getelementptr inbounds i8*, i8** %8, i64 1
%10 = load i8*, i8** %9
%11 = call i64 @atoi(i8* %10)
%12 = trunc i64 %11 to i32
store i32 %12, i32* %6
%13 = load i32, i32* %6
%14 = xor i32 %13, -1
store i32 %14, i32* %7
%15 = load i32, i32* %6
%16 = call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i32, i32* %7
%18 = call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %17)
%19 = load i32, i32* %6
%20 = load i32, i32* %7
%21 = or i32 %19, %20
%22 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 %21)
%23 = load i32, i32* %6
%24 = load i32, i32* %7
%25 = and i32 %23, %24
%26 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 %25)
%27 = load i32, i32* %6
%28 = xor i32 %27, -1
%29 = or i32 %28, 1
%30 = load i32, i32* %6
%31 = and i32 %29, %30
%32 = call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %31)
ret i32 0
}

LLVM IR (-O2):
@.str = [10 x i8] c"x = [%u]\0A\00"
@.str.1 = [11 x i8] c"~x = [%u]\0A\00"
@.str.2 = [15 x i8] c"x | ~x = [%u]\0A\00"
@.str.3 = [15 x i8] c"x & ~x = [%u]\0A\00"
@.str.4 = [21 x i8] c"(~x | 1) & x = [%u]\0A\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = getelementptr inbounds i8*, i8** %1, i64 1
%4 = load i8*, i8** %3
%5 = tail call i64 @atoi(i8* %4)
%6 = trunc i64 %5 to i32
%7 = xor i32 %6, -1
%8 = tail call i32 @printf(i8* getelementptr inbounds ([10 x i8], [10 x i8]* @.str, i64 0, i64 0), i32 %6)
%9 = tail call i32 @printf(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str.1, i64 0, i64 0), i32 %7)
%10 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0), i32 -1)
%11 = tail call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.3, i64 0, i64 0), i32 0)
%12 = and i32 %6, 1
%13 = tail call i32 @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i32 %12)
ret i32 0
}