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

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
scalar_t__ fgets(char *, int, int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char const *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, char *);
int /*<<< orphan*/ sprintf(char *, char *, char *);
int /*<<< orphan*/ strcpy(char *, char *);
scalar_t__ strstr(char *, char *);
void pnpremove(const char *in_path, const char *out_path) {
  char buffer[2][1024];
  FILE *fp_r = fopen(in_path, "r");
  FILE *fp_w = fopen(out_path, "w");
  if (fp_r) {
    while (fgets(buffer[1], sizeof(buffer[0]) / sizeof(buffer[0][0]), fp_r)) {
      if (strstr(buffer[1], "VID_0A12&PID_4010")) {
        if (strstr(buffer[0], "INF")) {
          char cmd[1024];
          sprintf(cmd, "Pnputil.exe -f -d %s", &buffer[0][11]);
          if (fp_w) {
            fprintf(fp_w, "%s\n", cmd);
          }
        }
      }
      strcpy(buffer[0], buffer[1]);
    }
    fclose(fp_r);
  }
  if (fp_w) {
    fclose(fp_w);
  }
}


x86 assembly (clang, -O0):
<pnpremove>:
push   %rbp
mov    %rsp,%rbp
sub    $0xc20,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x8(%rbp),%rdi
lea    0xe72(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x818(%rbp)
mov    -0x10(%rbp),%rdi
lea    0xe5d(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x820(%rbp)
cmpq   $0x0,-0x818(%rbp)
je     12a9 <pnpremove+0x139>
jmp    11c4 <pnpremove+0x54>
lea    -0x810(%rbp),%rdi
add    $0x400,%rdi
mov    -0x818(%rbp),%rdx
mov    $0x400,%esi
call   1050 <fgets@plt>
cmp    $0x0,%rax
je     129d <pnpremove+0x12d>
lea    -0x810(%rbp),%rdi
add    $0x400,%rdi
lea    0xe02(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
je     127e <pnpremove+0x10e>
lea    -0x810(%rbp),%rdi
lea    0xdf7(%rip),%rsi
call   1090 <strstr@plt>
cmp    $0x0,%rax
je     1279 <pnpremove+0x109>
lea    -0xc20(%rbp),%rdi
lea    -0x810(%rbp),%rdx
add    $0xb,%rdx
lea    0xdd3(%rip),%rsi
call   1080 <sprintf@plt>
cmpq   $0x0,-0x820(%rbp)
je     1274 <pnpremove+0x104>
mov    -0x820(%rbp),%rdi
lea    -0xc20(%rbp),%rdx
lea    0xdc0(%rip),%rsi
call   1060 <fprintf@plt>
jmp    1279 <pnpremove+0x109>
jmp    127e <pnpremove+0x10e>
lea    -0x810(%rbp),%rdi
lea    -0x810(%rbp),%rsi
add    $0x400,%rsi
call   1030 <strcpy@plt>
jmp    11c4 <pnpremove+0x54>
mov    -0x818(%rbp),%rdi
call   1040 <fclose@plt>
cmpq   $0x0,-0x820(%rbp)
je     12c3 <pnpremove+0x153>
mov    -0x820(%rbp),%rdi
call   1040 <fclose@plt>
add    $0xc20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<pnpremove>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0xc08,%rsp
mov    %rsi,%rbx
lea    0xe75(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r15
lea    0xe68(%rip),%rsi
mov    %rbx,%rdi
call   1070 <fopen@plt>
mov    %rax,%r14
test   %r15,%r15
je     1269 <pnpremove+0xf9>
lea    0x400(%rsp),%rbx
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1261 <pnpremove+0xf1>
lea    0xe2e(%rip),%r13
mov    %rsp,%rbp
lea    0x800(%rsp),%r12
jmp    1210 <pnpremove+0xa0>
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %rbp,%rdi
mov    %rbx,%rsi
call   1030 <strcpy@plt>
mov    %rbx,%rdi
mov    $0x400,%esi
mov    %r15,%rdx
call   1050 <fgets@plt>
test   %rax,%rax
je     1261 <pnpremove+0xf1>
mov    %rbx,%rdi
mov    %r13,%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     11f0 <pnpremove+0x80>
mov    %rbp,%rdi
lea    0xdec(%rip),%rsi
call   1090 <strstr@plt>
test   %rax,%rax
je     11f0 <pnpremove+0x80>
mov    %r12,%rdi
lea    0xddc(%rip),%rsi
lea    0xb(%rsp),%rdx
call   1080 <sprintf@plt>
test   %r14,%r14
je     11f0 <pnpremove+0x80>
mov    %r14,%rdi
lea    0xdd8(%rip),%rsi
mov    %r12,%rdx
call   1060 <fprintf@plt>
jmp    11f0 <pnpremove+0x80>
mov    %r15,%rdi
call   1040 <fclose@plt>
test   %r14,%r14
je     1276 <pnpremove+0x106>
mov    %r14,%rdi
call   1040 <fclose@plt>
add    $0xc08,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [18 x i8] c"VID_0A12&PID_4010\00"
@.str.3 = [4 x i8] c"INF\00"
@.str.4 = [21 x i8] c"Pnputil.exe -f -d %s\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define void @pnpremove(i8* %0, i8* %1) {
%3 = alloca i8*
%4 = alloca i8*
%5 = alloca [2 x [1024 x i8]]
%6 = alloca i32*
%7 = alloca i32*
%8 = alloca [1024 x i8]
store i8* %0, i8** %3
store i8* %1, i8** %4
%9 = load i8*, i8** %3
%10 = call i32* @fopen(i8* %9, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %10, i32** %6
%11 = load i8*, i8** %4
%12 = call i32* @fopen(i8* %11, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %12, i32** %7
%13 = load i32*, i32** %6
%14 = icmp ne i32* %13, null
br i1 %14, label %15, label %54
15: ; preds = %2
br label %16
16: ; preds = %45, %15
%17 = getelementptr inbounds [2 x [1024 x i8]], [2 x [1024 x i8]]* %5, i64 0, i64 1
%18 = getelementptr inbounds [1024 x i8], [1024 x i8]* %17, i64 0, i64 0
%19 = load i32*, i32** %6
%20 = call i64 @fgets(i8* %18, i32 1024, i32* %19)
%21 = icmp ne i64 %20, 0
br i1 %21, label %22, label %51
22: ; preds = %16
%23 = getelementptr inbounds [2 x [1024 x i8]], [2 x [1024 x i8]]* %5, i64 0, i64 1
%24 = getelementptr inbounds [1024 x i8], [1024 x i8]* %23, i64 0, i64 0
%25 = call i64 @strstr(i8* %24, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%26 = icmp ne i64 %25, 0
br i1 %26, label %27, label %45
27: ; preds = %22
%28 = getelementptr inbounds [2 x [1024 x i8]], [2 x [1024 x i8]]* %5, i64 0, i64 0
%29 = getelementptr inbounds [1024 x i8], [1024 x i8]* %28, i64 0, i64 0
%30 = call i64 @strstr(i8* %29, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%31 = icmp ne i64 %30, 0
br i1 %31, label %32, label %44
32: ; preds = %27
%33 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%34 = getelementptr inbounds [2 x [1024 x i8]], [2 x [1024 x i8]]* %5, i64 0, i64 0
%35 = getelementptr inbounds [1024 x i8], [1024 x i8]* %34, i64 0, i64 11
%36 = call i32 @sprintf(i8* %33, i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %35)
%37 = load i32*, i32** %7
%38 = icmp ne i32* %37, null
br i1 %38, label %39, label %43
39: ; preds = %32
%40 = load i32*, i32** %7
%41 = getelementptr inbounds [1024 x i8], [1024 x i8]* %8, i64 0, i64 0
%42 = call i32 @fprintf(i32* %40, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %41)
br label %43
43: ; preds = %39, %32
br label %44
44: ; preds = %43, %27
br label %45
45: ; preds = %44, %22
%46 = getelementptr inbounds [2 x [1024 x i8]], [2 x [1024 x i8]]* %5, i64 0, i64 0
%47 = getelementptr inbounds [1024 x i8], [1024 x i8]* %46, i64 0, i64 0
%48 = getelementptr inbounds [2 x [1024 x i8]], [2 x [1024 x i8]]* %5, i64 0, i64 1
%49 = getelementptr inbounds [1024 x i8], [1024 x i8]* %48, i64 0, i64 0
%50 = call i32 @strcpy(i8* %47, i8* %49)
br label %16
51: ; preds = %16
%52 = load i32*, i32** %6
%53 = call i32 @fclose(i32* %52)
br label %54
54: ; preds = %51, %2
%55 = load i32*, i32** %7
%56 = icmp ne i32* %55, null
br i1 %56, label %57, label %60
57: ; preds = %54
%58 = load i32*, i32** %7
%59 = call i32 @fclose(i32* %58)
br label %60
60: ; preds = %57, %54
ret void
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [2 x i8] c"w\00"
@.str.2 = [18 x i8] c"VID_0A12&PID_4010\00"
@.str.3 = [4 x i8] c"INF\00"
@.str.4 = [21 x i8] c"Pnputil.exe -f -d %s\00"
@.str.5 = [4 x i8] c"%s\0A\00"
define void @pnpremove(i8* nocapture %0, i8* nocapture %1) {
%3 = alloca [2 x [1024 x i8]]
%4 = alloca [1024 x i8]
%5 = getelementptr inbounds [2 x [1024 x i8]], [2 x [1024 x i8]]* %3, i64 0, i64 0, i64 0
%6 = tail call i32* @fopen(i8* %0, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%7 = tail call i32* @fopen(i8* %1, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %6, null
br i1 %8, label %34, label %9
9: ; preds = %2
%10 = getelementptr inbounds [2 x [1024 x i8]], [2 x [1024 x i8]]* %3, i64 0, i64 1, i64 0
%11 = call i64 @fgets(i8* %10, i32 1024, i32* %6)
%12 = icmp eq i64 %11, 0
br i1 %12, label %32, label %13
13: ; preds = %9
%14 = getelementptr inbounds [1024 x i8], [1024 x i8]* %4, i64 0, i64 0
%15 = getelementptr inbounds [2 x [1024 x i8]], [2 x [1024 x i8]]* %3, i64 0, i64 0, i64 11
%16 = icmp eq i32* %7, null
br label %17
17: ; preds = %13, %28
%18 = call i64 @strstr(i8* %10, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str.2, i64 0, i64 0))
%19 = icmp eq i64 %18, 0
br i1 %19, label %28, label %20
20: ; preds = %17
%21 = call i64 @strstr(i8* %5, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.3, i64 0, i64 0))
%22 = icmp eq i64 %21, 0
br i1 %22, label %28, label %23
23: ; preds = %20
%24 = call i32 @sprintf(i8* %14, i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.4, i64 0, i64 0), i8* %15)
br i1 %16, label %27, label %25
25: ; preds = %23
%26 = call i32 @fprintf(i32* %7, i8* getelementptr inbounds ([4 x i8], [4 x i8]* @.str.5, i64 0, i64 0), i8* %14)
br label %27
27: ; preds = %25, %23
br label %28
28: ; preds = %20, %27, %17
%29 = call i32 @strcpy(i8* %5, i8* %10)
%30 = call i64 @fgets(i8* %10, i32 1024, i32* %6)
%31 = icmp eq i64 %30, 0
br i1 %31, label %32, label %17
32: ; preds = %28, %9
%33 = call i32 @fclose(i32* %6)
br label %34
34: ; preds = %32, %2
%35 = icmp eq i32* %7, null
br i1 %35, label %38, label %36
36: ; preds = %34
%37 = call i32 @fclose(i32* %7)
br label %38
38: ; preds = %36, %34
ret void
}