#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 */
typedef int /*<<< orphan*/ l;
typedef int /*<<< orphan*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fputs(char *, int /*<<< orphan*/ *);
int /*<<< orphan*/ free(void *);
void *malloc(scalar_t__);
int /*<<< orphan*/ rename(char *, char *);
int /*<<< orphan*/ stopErr(char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strlen(char *);
void GPF_supL(char *f, int n) {
  void *M;
  char *f2;
  char l[512];
  FILE *fIn, *fOut;
  int i = 1;
  if ((M = malloc(strlen(f) + 5)) == NULL)
    stopErr("GPF_supL", "malloc");
  f2 = (char *)M;
  strcpy(f2, f);
  f2 += strlen(f);
  strcpy(f2, ".wni");
  f2 = (char *)M;
  if ((fIn = fopen(f, "r")) != NULL) {
    if ((fOut = fopen(f2, "w")) != NULL) {
      while (fgets(l, sizeof(l), fIn)) {
        if (i != n)
          fputs(l, fOut);
        i++;
      }
      fclose(fOut);
    }
    fclose(fIn);
    rename(f2, f);
  }
  free(M);
}


x86 assembly (clang, -O0):
<GPF_supL>:
push   %rbp
mov    %rsp,%rbp
sub    $0x240,%rsp
mov    %rdi,-0x8(%rbp)
mov    %esi,-0xc(%rbp)
movl   $0x1,-0x234(%rbp)
mov    -0x8(%rbp),%rdi
call   1070 <strlen@plt>
mov    %rax,%rdi
add    $0x5,%rdi
call   10a0 <malloc@plt>
mov    %rax,-0x18(%rbp)
cmp    $0x0,%rax
jne    11f2 <GPF_supL+0x52>
lea    0xe1a(%rip),%rdi
lea    0xe1c(%rip),%rsi
call   1050 <stopErr@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   1040 <strcpy@plt>
mov    -0x8(%rbp),%rdi
call   1070 <strlen@plt>
add    -0x20(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x20(%rbp),%rdi
lea    0xded(%rip),%rsi
call   1040 <strcpy@plt>
mov    -0x18(%rbp),%rax
mov    %rax,-0x20(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xdda(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x228(%rbp)
cmp    $0x0,%rax
je     12f4 <GPF_supL+0x154>
mov    -0x20(%rbp),%rdi
lea    0xdbb(%rip),%rsi
call   10b0 <fopen@plt>
mov    %rax,-0x230(%rbp)
cmp    $0x0,%rax
je     12db <GPF_supL+0x13b>
jmp    1277 <GPF_supL+0xd7>
lea    -0x220(%rbp),%rdi
mov    -0x228(%rbp),%rdx
mov    $0x200,%esi
call   1090 <fgets@plt>
cmp    $0x0,%rax
je     12cf <GPF_supL+0x12f>
mov    -0x234(%rbp),%eax
cmp    -0xc(%rbp),%eax
je     12bb <GPF_supL+0x11b>
lea    -0x220(%rbp),%rdi
mov    -0x230(%rbp),%rsi
call   1080 <fputs@plt>
mov    -0x234(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x234(%rbp)
jmp    1277 <GPF_supL+0xd7>
mov    -0x230(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x228(%rbp),%rdi
call   1060 <fclose@plt>
mov    -0x20(%rbp),%rdi
mov    -0x8(%rbp),%rsi
call   10c0 <rename@plt>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
add    $0x240,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<GPF_supL>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x208,%rsp
mov    %esi,%ebp
mov    %rdi,%r14
call   1070 <strlen@plt>
lea    0x5(%rax),%rdi
call   10a0 <malloc@plt>
mov    %rax,%r15
test   %rax,%rax
jne    11df <GPF_supL+0x3f>
lea    0xe2d(%rip),%rdi
lea    0xe2f(%rip),%rsi
call   1050 <stopErr@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   1040 <strcpy@plt>
mov    %r14,%rdi
call   1070 <strlen@plt>
mov    %r15,%rdi
add    %rax,%rdi
lea    0xe11(%rip),%rsi
call   1040 <strcpy@plt>
lea    0xe0a(%rip),%rsi
mov    %r14,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     1292 <GPF_supL+0xf2>
mov    %rax,%rbx
lea    0xdf5(%rip),%rsi
mov    %r15,%rdi
call   10b0 <fopen@plt>
test   %rax,%rax
je     127f <GPF_supL+0xdf>
mov    %rax,%r12
mov    %rsp,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1277 <GPF_supL+0xd7>
add    $0xffffffff,%ebp
mov    %rsp,%r13
jmp    1265 <GPF_supL+0xc5>
nop
mov    %r13,%rdi
mov    $0x200,%esi
mov    %rbx,%rdx
call   1090 <fgets@plt>
test   %rax,%rax
je     1277 <GPF_supL+0xd7>
sub    $0x1,%ebp
jb     1250 <GPF_supL+0xb0>
mov    %r13,%rdi
mov    %r12,%rsi
call   1080 <fputs@plt>
jmp    1250 <GPF_supL+0xb0>
mov    %r12,%rdi
call   1060 <fclose@plt>
mov    %rbx,%rdi
call   1060 <fclose@plt>
mov    %r15,%rdi
mov    %r14,%rsi
call   10c0 <rename@plt>
mov    %r15,%rdi
call   1030 <free@plt>
add    $0x208,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [9 x i8] c"GPF_supL\00"
@.str.1 = [7 x i8] c"malloc\00"
@.str.2 = [5 x i8] c".wni\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [2 x i8] c"w\00"
define void @GPF_supL(i8* %0, i32 %1) {
%3 = alloca i8*
%4 = alloca i32
%5 = alloca i8*
%6 = alloca i8*
%7 = alloca [512 x i8]
%8 = alloca i32*
%9 = alloca i32*
%10 = alloca i32
store i8* %0, i8** %3
store i32 %1, i32* %4
store i32 1, i32* %10
%11 = load i8*, i8** %3
%12 = call i64 @strlen(i8* %11)
%13 = add nsw i64 %12, 5
%14 = call i8* @malloc(i64 %13)
store i8* %14, i8** %5
%15 = icmp eq i8* %14, null
br i1 %15, label %16, label %18
16: ; preds = %2
%17 = call i32 @stopErr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %18
18: ; preds = %16, %2
%19 = load i8*, i8** %5
store i8* %19, i8** %6
%20 = load i8*, i8** %6
%21 = load i8*, i8** %3
%22 = call i32 @strcpy(i8* %20, i8* %21)
%23 = load i8*, i8** %3
%24 = call i64 @strlen(i8* %23)
%25 = load i8*, i8** %6
%26 = getelementptr inbounds i8, i8* %25, i64 %24
store i8* %26, i8** %6
%27 = load i8*, i8** %6
%28 = call i32 @strcpy(i8* %27, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%29 = load i8*, i8** %5
store i8* %29, i8** %6
%30 = load i8*, i8** %3
%31 = call i32* @fopen(i8* %30, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %31, i32** %8
%32 = icmp ne i32* %31, null
br i1 %32, label %33, label %63
33: ; preds = %18
%34 = load i8*, i8** %6
%35 = call i32* @fopen(i8* %34, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
store i32* %35, i32** %9
%36 = icmp ne i32* %35, null
br i1 %36, label %37, label %57
37: ; preds = %33
br label %38
38: ; preds = %51, %37
%39 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%40 = load i32*, i32** %8
%41 = call i64 @fgets(i8* %39, i32 512, i32* %40)
%42 = icmp ne i64 %41, 0
br i1 %42, label %43, label %54
43: ; preds = %38
%44 = load i32, i32* %10
%45 = load i32, i32* %4
%46 = icmp ne i32 %44, %45
br i1 %46, label %47, label %51
47: ; preds = %43
%48 = getelementptr inbounds [512 x i8], [512 x i8]* %7, i64 0, i64 0
%49 = load i32*, i32** %9
%50 = call i32 @fputs(i8* %48, i32* %49)
br label %51
51: ; preds = %47, %43
%52 = load i32, i32* %10
%53 = add nsw i32 %52, 1
store i32 %53, i32* %10
br label %38
54: ; preds = %38
%55 = load i32*, i32** %9
%56 = call i32 @fclose(i32* %55)
br label %57
57: ; preds = %54, %33
%58 = load i32*, i32** %8
%59 = call i32 @fclose(i32* %58)
%60 = load i8*, i8** %6
%61 = load i8*, i8** %3
%62 = call i32 @rename(i8* %60, i8* %61)
br label %63
63: ; preds = %57, %18
%64 = load i8*, i8** %5
%65 = call i32 @free(i8* %64)
ret void
}

LLVM IR (-O2):
@.str = [9 x i8] c"GPF_supL\00"
@.str.1 = [7 x i8] c"malloc\00"
@.str.2 = [5 x i8] c".wni\00"
@.str.3 = [2 x i8] c"r\00"
@.str.4 = [2 x i8] c"w\00"
define void @GPF_supL(i8* %0, i32 %1) {
%3 = alloca [512 x i8]
%4 = getelementptr inbounds [512 x i8], [512 x i8]* %3, i64 0, i64 0
%5 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%6 = add nsw i64 %5, 5
%7 = tail call i8* @malloc(i64 %6)
%8 = icmp eq i8* %7, null
br i1 %8, label %9, label %11
9: ; preds = %2
%10 = tail call i32 @stopErr(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.1, i64 0, i64 0))
br label %11
11: ; preds = %9, %2
%12 = tail call i32 @strcpy(i8* %7, i8* %0)
%13 = tail call i64 @strlen(i8* dereferenceable(1) %0)
%14 = getelementptr inbounds i8, i8* %7, i64 %13
%15 = tail call i32 @strcpy(i8* %14, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.2, i64 0, i64 0))
%16 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%17 = icmp eq i32* %16, null
br i1 %17, label %38, label %18
18: ; preds = %11
%19 = tail call i32* @fopen(i8* %7, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.4, i64 0, i64 0))
%20 = icmp eq i32* %19, null
br i1 %20, label %35, label %21
21: ; preds = %18
%22 = call i64 @fgets(i8* %4, i32 512, i32* %16)
%23 = icmp eq i64 %22, 0
br i1 %23, label %33, label %24
24: ; preds = %21, %29
%25 = phi i32 [ %30, %29 ], [ 1, %21 ]
%26 = icmp eq i32 %25, %1
br i1 %26, label %29, label %27
27: ; preds = %24
%28 = call i32 @fputs(i8* %4, i32* %19)
br label %29
29: ; preds = %27, %24
%30 = add nuw nsw i32 %25, 1
%31 = call i64 @fgets(i8* %4, i32 512, i32* %16)
%32 = icmp eq i64 %31, 0
br i1 %32, label %33, label %24
33: ; preds = %29, %21
%34 = call i32 @fclose(i32* %19)
br label %35
35: ; preds = %33, %18
%36 = call i32 @fclose(i32* %16)
%37 = call i32 @rename(i8* %7, i8* %0)
br label %38
38: ; preds = %35, %11
%39 = call i32 @free(i8* %7)
ret void
}