#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*/ SEEK_END;
int /*<<< orphan*/ _edit(int const, char, char *);
int /*<<< orphan*/ encode(char *);
int /*<<< orphan*/ lseek(int const, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, char *);
int /*<<< orphan*/ strlen(char *);
int /*<<< orphan*/ write(int const, char *, int /*<<< orphan*/);
void edit(const int fd, char op, char *user) {
  switch (op) {
  case 0x2:
    _edit(fd, op, user);
    break;
  case 0x4:
    encode(user);
    lseek(fd, 0, SEEK_END);
    write(fd, user, strlen(user));
    break;
  case 0x8:
    _edit(fd, op, user);
    break;
  case 0x10:
    encode(user);
    printf("%s\n", user);
    break;
  }
}


x86 assembly (clang, -O0):
<edit>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
mov    %sil,%al
mov    %edi,-0x4(%rbp)
mov    %al,-0x5(%rbp)
mov    %rdx,-0x10(%rbp)
movsbl -0x5(%rbp),%eax
add    $0xfffffffe,%eax
mov    %eax,%ecx
mov    %rcx,-0x18(%rbp)
sub    $0xe,%eax
ja     122c <edit+0xcc>
mov    -0x18(%rbp),%rax
lea    0xe6a(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
mov    -0x4(%rbp),%edi
mov    -0x5(%rbp),%al
mov    -0x10(%rbp),%rdx
movsbl %al,%esi
call   1050 <_edit@plt>
jmp    122c <edit+0xcc>
mov    -0x10(%rbp),%rdi
call   1030 <encode@plt>
mov    -0x4(%rbp),%edi
mov    0x2e1f(%rip),%rax
mov    (%rax),%edx
xor    %esi,%esi
call   1080 <lseek@plt>
mov    -0x4(%rbp),%eax
mov    %eax,-0x24(%rbp)
mov    -0x10(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x10(%rbp),%rdi
call   1060 <strlen@plt>
mov    -0x24(%rbp),%edi
mov    -0x20(%rbp),%rsi
mov    %eax,%edx
call   1040 <write@plt>
jmp    122c <edit+0xcc>
mov    -0x4(%rbp),%edi
mov    -0x5(%rbp),%al
mov    -0x10(%rbp),%rdx
movsbl %al,%esi
call   1050 <_edit@plt>
jmp    122c <edit+0xcc>
mov    -0x10(%rbp),%rdi
call   1030 <encode@plt>
mov    -0x10(%rbp),%rsi
lea    0xe15(%rip),%rdi
call   1070 <printf@plt>
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<edit>:
push   %rbp
push   %rbx
push   %rax
lea    -0x2(%rsi),%eax
ror    %eax
cmp    $0x7,%eax
ja     11ca <edit+0x6a>
mov    %rdx,%rbx
mov    %edi,%ebp
lea    0xe87(%rip),%rcx
movslq (%rcx,%rax,4),%rax
add    %rcx,%rax
jmp    *%rax
movsbl %sil,%esi
mov    %ebp,%edi
mov    %rbx,%rdx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1050 <_edit@plt>
mov    %rbx,%rdi
call   1030 <encode@plt>
mov    0x2e43(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
xor    %esi,%esi
call   1080 <lseek@plt>
mov    %rbx,%rdi
call   1060 <strlen@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
mov    %eax,%edx
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1040 <write@plt>
add    $0x8,%rsp
pop    %rbx
pop    %rbp
ret
mov    %rbx,%rdi
call   1030 <encode@plt>
lea    0xe40(%rip),%rdi
mov    %rbx,%rsi
add    $0x8,%rsp
pop    %rbx
pop    %rbp
jmp    1070 <printf@plt>

LLVM IR (-O0):
@SEEK_END = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define void @edit(i32 %0, i8 signext %1, i8* %2) {
%4 = alloca i32
%5 = alloca i8
%6 = alloca i8*
store i32 %0, i32* %4
store i8 %1, i8* %5
store i8* %2, i8** %6
%7 = load i8, i8* %5
%8 = sext i8 %7 to i32
switch i32 %8, label %35 [
i32 2, label %9
i32 4, label %14
i32 8, label %25
i32 16, label %30
]
9: ; preds = %3
%10 = load i32, i32* %4
%11 = load i8, i8* %5
%12 = load i8*, i8** %6
%13 = call i32 @_edit(i32 %10, i8 signext %11, i8* %12)
br label %35
14: ; preds = %3
%15 = load i8*, i8** %6
%16 = call i32 @encode(i8* %15)
%17 = load i32, i32* %4
%18 = load i32, i32* @SEEK_END
%19 = call i32 @lseek(i32 %17, i32 0, i32 %18)
%20 = load i32, i32* %4
%21 = load i8*, i8** %6
%22 = load i8*, i8** %6
%23 = call i32 @strlen(i8* %22)
%24 = call i32 @write(i32 %20, i8* %21, i32 %23)
br label %35
25: ; preds = %3
%26 = load i32, i32* %4
%27 = load i8, i8* %5
%28 = load i8*, i8** %6
%29 = call i32 @_edit(i32 %26, i8 signext %27, i8* %28)
br label %35
30: ; preds = %3
%31 = load i8*, i8** %6
%32 = call i32 @encode(i8* %31)
%33 = load i8*, i8** %6
%34 = call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %33)
br label %35
35: ; preds = %3, %30, %25, %14, %9
ret void
}

LLVM IR (-O2):
@SEEK_END = global i32 0
@.str = [4 x i8] c"%s\0A\00"
define void @edit(i32 %0, i8 signext %1, i8* %2) {
%4 = sext i8 %1 to i32
%5 = add nsw i32 %4, -2
%6 = tail call i32 @llvm.fshl.i32(i32 %5, i32 %5, i32 31)
switch i32 %6, label %20 [
i32 0, label %7
i32 1, label %9
i32 3, label %15
i32 7, label %17
]
7: ; preds = %3
%8 = tail call i32 @_edit(i32 %0, i8 signext %1, i8* %2)
br label %20
9: ; preds = %3
%10 = tail call i32 @encode(i8* %2)
%11 = load i32, i32* @SEEK_END
%12 = tail call i32 @lseek(i32 %0, i32 0, i32 %11)
%13 = tail call i32 @strlen(i8* %2)
%14 = tail call i32 @write(i32 %0, i8* %2, i32 %13)
br label %20
15: ; preds = %3
%16 = tail call i32 @_edit(i32 %0, i8 signext %1, i8* %2)
br label %20
17: ; preds = %3
%18 = tail call i32 @encode(i8* %2)
%19 = tail call i32 @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %2)
br label %20
20: ; preds = %3, %17, %15, %9, %7
ret void
}