#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*/ O_RDWR;
int /*<<< orphan*/ SEEK_SET;
int /*<<< orphan*/ close(int);
int /*<<< orphan*/ lseek(int, long, int /*<<< orphan*/);
int open(char *, int /*<<< orphan*/);
int /*<<< orphan*/ printf(char *, ...);
int write(int, char *, int);
void undelete_for_long(char *path, long offset, char *signal) {
  int fp = open(path, O_RDWR);
  printf("%s\n", path);
  printf("%li\n", offset);
  lseek(fp, offset, SEEK_SET);
  int b = write(fp, signal, 1);
  printf("%d\n", b);
  printf("%s\n", "working");
  close(fp);
}


x86 assembly (clang, -O0):
<undelete_for_long>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %rdx,-0x18(%rbp)
mov    -0x8(%rbp),%rdi
mov    0x2e79(%rip),%rax
mov    (%rax),%esi
call   1070 <open@plt>
mov    %eax,-0x1c(%rbp)
mov    -0x8(%rbp),%rsi
lea    0xe7c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x10(%rbp),%rsi
lea    0xe6e(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x10(%rbp),%rsi
mov    0x2e2d(%rip),%rax
mov    (%rax),%edx
call   1050 <lseek@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
mov    $0x1,%edx
call   1030 <write@plt>
mov    %eax,-0x20(%rbp)
mov    -0x20(%rbp),%esi
lea    0xe39(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe22(%rip),%rdi
lea    0xe28(%rip),%rsi
mov    $0x0,%al
call   1040 <printf@plt>
mov    -0x1c(%rbp),%edi
call   1060 <close@plt>
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<undelete_for_long>:
push   %rbp
push   %r15
push   %r14
push   %rbx
push   %rax
mov    %rdx,%r14
mov    %rsi,%r15
mov    %rdi,%rbx
mov    0x2e71(%rip),%rax
mov    (%rax),%esi
call   1080 <open@plt>
mov    %eax,%ebp
mov    %rbx,%rdi
call   1030 <puts@plt>
lea    0xe71(%rip),%rdi
mov    %r15,%rsi
xor    %eax,%eax
call   1050 <printf@plt>
mov    0x2e38(%rip),%rax
mov    (%rax),%edx
mov    %ebp,%edi
mov    %r15,%rsi
call   1060 <lseek@plt>
mov    %ebp,%edi
mov    %r14,%rsi
mov    $0x1,%edx
call   1040 <write@plt>
lea    0xe43(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xe37(%rip),%rdi
call   1030 <puts@plt>
mov    %ebp,%edi
add    $0x8,%rsp
pop    %rbx
pop    %r14
pop    %r15
pop    %rbp
jmp    1070 <close@plt>

LLVM IR (-O0):
@O_RDWR = global i32 0
@.str = [4 x i8] c"%s\0A\00"
@.str.1 = [5 x i8] c"%li\0A\00"
@SEEK_SET = global i32 0
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [8 x i8] c"working\00"
define void @undelete_for_long(i8* %0, i64 %1, i8* %2) {
%4 = alloca i8*
%5 = alloca i64
%6 = alloca i8*
%7 = alloca i32
%8 = alloca i32
store i8* %0, i8** %4
store i64 %1, i64* %5
store i8* %2, i8** %6
%9 = load i8*, i8** %4
%10 = load i32, i32* @O_RDWR
%11 = call i32 @open(i8* %9, i32 %10)
store i32 %11, i32* %7
%12 = load i8*, i8** %4
%13 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* %12)
%14 = load i64, i64* %5
%15 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %14)
%16 = load i32, i32* %7
%17 = load i64, i64* %5
%18 = load i32, i32* @SEEK_SET
%19 = call i32 @lseek(i32 %16, i64 %17, i32 %18)
%20 = load i32, i32* %7
%21 = load i8*, i8** %6
%22 = call i32 @write(i32 %20, i8* %21, i32 1)
store i32 %22, i32* %8
%23 = load i32, i32* %8
%24 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %23)
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%26 = load i32, i32* %7
%27 = call i32 @close(i32 %26)
ret void
}

LLVM IR (-O2):
@O_RDWR = global i32 0
@.str.1 = [5 x i8] c"%li\0A\00"
@SEEK_SET = global i32 0
@.str.2 = [4 x i8] c"%d\0A\00"
@.str.3 = [8 x i8] c"working\00"
define void @undelete_for_long(i8* nocapture %0, i64 %1, i8* nocapture %2) {
%4 = load i32, i32* @O_RDWR
%5 = tail call i32 @open(i8* %0, i32 %4)
%6 = tail call i32 @puts(i8* dereferenceable(1) %0)
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([5 x i8], [5 x i8]* @.str.1, i64 0, i64 0), i64 %1)
%8 = load i32, i32* @SEEK_SET
%9 = tail call i32 @lseek(i32 %5, i64 %1, i32 %8)
%10 = tail call i32 @write(i32 %5, i8* %2, i32 1)
%11 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([4 x i8], [4 x i8]* @.str.2, i64 0, i64 0), i32 %10)
%12 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([8 x i8], [8 x i8]* @.str.3, i64 0, i64 0))
%13 = tail call i32 @close(i32 %5)
ret void
}