#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 */
struct dc {
  int dummy;
};

/* Variables and functions */
int dc_pop(struct dc *);
int /*<<< orphan*/ dc_push(struct dc *, int);
int /*<<< orphan*/ errx(int, char *, char *);
void dcf_unop(struct dc *dc, char *cmd) {
  int v = dc_pop(dc);
  switch (*cmd) {
  case '!':
    v = !v;
    break;
  case '~':
    v = ~v;
    break;
  default:
    errx(2, "unknown unop '%s'", cmd);
    break;
  }
  dc_push(dc, v);
}


x86 assembly (clang, -O0):
<dcf_unop>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
call   1050 <dc_pop@plt>
mov    %eax,-0x14(%rbp)
mov    -0x10(%rbp),%rax
movsbl (%rax),%eax
mov    %eax,-0x18(%rbp)
sub    $0x21,%eax
je     1175 <dcf_unop+0x45>
jmp    1164 <dcf_unop+0x34>
mov    -0x18(%rbp),%eax
sub    $0x7e,%eax
je     118b <dcf_unop+0x5b>
jmp    1199 <dcf_unop+0x69>
cmpl   $0x0,-0x14(%rbp)
setne  %al
xor    $0xff,%al
and    $0x1,%al
movzbl %al,%eax
mov    %eax,-0x14(%rbp)
jmp    11ae <dcf_unop+0x7e>
mov    -0x14(%rbp),%eax
xor    $0xffffffff,%eax
mov    %eax,-0x14(%rbp)
jmp    11ae <dcf_unop+0x7e>
mov    -0x10(%rbp),%rdx
mov    $0x2,%edi
lea    0xe57(%rip),%rsi
call   1040 <errx@plt>
mov    -0x8(%rbp),%rdi
mov    -0x14(%rbp),%esi
call   1030 <dc_push@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<dcf_unop>:
push   %rbp
push   %r14
push   %rbx
mov    %rsi,%rbx
mov    %rdi,%r14
call   1050 <dc_pop@plt>
mov    %eax,%ebp
movsbl (%rbx),%eax
cmp    $0x7e,%eax
je     1158 <dcf_unop+0x28>
cmp    $0x21,%eax
jne    115c <dcf_unop+0x2c>
xor    %esi,%esi
test   %ebp,%ebp
sete   %sil
jmp    1172 <dcf_unop+0x42>
not    %ebp
jmp    1170 <dcf_unop+0x40>
lea    0xe9d(%rip),%rsi
mov    $0x2,%edi
mov    %rbx,%rdx
call   1040 <errx@plt>
mov    %ebp,%esi
mov    %r14,%rdi
pop    %rbx
pop    %r14
pop    %rbp
jmp    1030 <dc_push@plt>

LLVM IR (-O0):
%struct.dc = type { i32 }
@.str = [18 x i8] c"unknown unop '%s'\00"
define void @dcf_unop(%struct.dc* %0, i8* %1) {
%3 = alloca %struct.dc*
%4 = alloca i8*
%5 = alloca i32
store %struct.dc* %0, %struct.dc** %3
store i8* %1, i8** %4
%6 = load %struct.dc*, %struct.dc** %3
%7 = call i32 @dc_pop(%struct.dc* %6)
store i32 %7, i32* %5
%8 = load i8*, i8** %4
%9 = load i8, i8* %8
%10 = sext i8 %9 to i32
switch i32 %10, label %19 [
i32 33, label %11
i32 126, label %16
]
11: ; preds = %2
%12 = load i32, i32* %5
%13 = icmp ne i32 %12, 0
%14 = xor i1 %13, true
%15 = zext i1 %14 to i32
store i32 %15, i32* %5
br label %22
16: ; preds = %2
%17 = load i32, i32* %5
%18 = xor i32 %17, -1
store i32 %18, i32* %5
br label %22
19: ; preds = %2
%20 = load i8*, i8** %4
%21 = call i32 @errx(i32 2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %20)
br label %22
22: ; preds = %19, %16, %11
%23 = load %struct.dc*, %struct.dc** %3
%24 = load i32, i32* %5
%25 = call i32 @dc_push(%struct.dc* %23, i32 %24)
ret void
}

LLVM IR (-O2):
%struct.dc = type { i32 }
@.str = [18 x i8] c"unknown unop '%s'\00"
define void @dcf_unop(%struct.dc* %0, i8* %1) {
%3 = tail call i32 @dc_pop(%struct.dc* %0)
%4 = load i8, i8* %1
%5 = sext i8 %4 to i32
switch i32 %5, label %11 [
i32 33, label %6
i32 126, label %9
]
6: ; preds = %2
%7 = icmp eq i32 %3, 0
%8 = zext i1 %7 to i32
br label %13
9: ; preds = %2
%10 = xor i32 %3, -1
br label %13
11: ; preds = %2
%12 = tail call i32 @errx(i32 2, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), i8* %1)
br label %13
13: ; preds = %11, %9, %6
%14 = phi i32 [ %3, %11 ], [ %10, %9 ], [ %8, %6 ]
%15 = tail call i32 @dc_push(%struct.dc* %0, i32 %14)
ret void
}