#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*/ FILE;

/* Variables and functions */
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fscanf(int /*<<< orphan*/ *, char *, float *);
int /*<<< orphan*/ fwrite(float *, int, int, int /*<<< orphan*/ *);
scalar_t__ malloc(int);
int /*<<< orphan*/ sscanf(char *, char *, int *);
main(int argc, char *argv[]) {
  int i, lines, mics;
  float *buf;
  FILE *f = fopen(argv[1], "r");
  sscanf(argv[2], "%d", &lines);
  sscanf(argv[3], "%d", &mics);
  buf = (float *)malloc(lines * mics * sizeof(float));
  for (i = 0; i < lines * mics; i++)
    fscanf(f, "%f", &buf[i]);
  fclose(f);
  f = fopen(argv[4], "w");
  fwrite(&buf[0], lines * mics * sizeof(float), 1, f);
  fclose(f);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    -0x10(%rbp),%rax
mov    0x8(%rax),%rdi
lea    0xe7b(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x10(%rbp),%rax
mov    0x10(%rax),%rdi
lea    0xe65(%rip),%rsi
lea    -0x18(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x10(%rbp),%rax
mov    0x18(%rax),%rdi
lea    0xe4d(%rip),%rsi
lea    -0x1c(%rbp),%rdx
call   1060 <sscanf@plt>
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%edi
call   1050 <malloc@plt>
mov    %rax,-0x28(%rbp)
movl   $0x0,-0x14(%rbp)
mov    -0x14(%rbp),%eax
mov    -0x18(%rbp),%ecx
imul   -0x1c(%rbp),%ecx
cmp    %ecx,%eax
jge    121c <main+0xbc>
mov    -0x30(%rbp),%rdi
mov    -0x28(%rbp),%rdx
movslq -0x14(%rbp),%rax
shl    $0x2,%rax
add    %rax,%rdx
lea    0xdfc(%rip),%rsi
call   1040 <fscanf@plt>
mov    -0x14(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x14(%rbp)
jmp    11dd <main+0x7d>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x10(%rbp),%rax
mov    0x20(%rax),%rdi
lea    0xdd4(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,-0x30(%rbp)
mov    -0x28(%rbp),%rdi
mov    -0x18(%rbp),%eax
imul   -0x1c(%rbp),%eax
cltq
shl    $0x2,%rax
mov    %eax,%esi
mov    -0x30(%rbp),%rcx
mov    $0x1,%edx
call   1080 <fwrite@plt>
mov    -0x30(%rbp),%rdi
call   1030 <fclose@plt>
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
push   %rax
mov    %rsi,%r14
mov    0x8(%rsi),%rdi
lea    0xe87(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%r13
mov    0x10(%r14),%rdi
lea    0xe76(%rip),%rbx
lea    0x4(%rsp),%rdx
mov    %rbx,%rsi
call   1060 <sscanf@plt>
mov    0x18(%r14),%rdi
mov    %rsp,%rdx
mov    %rbx,%rsi
call   1060 <sscanf@plt>
mov    0x4(%rsp),%edi
imul   (%rsp),%edi
shl    $0x2,%edi
call   1050 <malloc@plt>
mov    %rax,%r15
mov    (%rsp),%eax
imul   0x4(%rsp),%eax
test   %eax,%eax
jle    1208 <main+0xa8>
xor    %ebp,%ebp
lea    0xe35(%rip),%r12
mov    %r15,%rbx
cs nopw 0x0(%rax,%rax,1)
nopl   (%rax)
mov    %r13,%rdi
mov    %r12,%rsi
mov    %rbx,%rdx
call   1040 <fscanf@plt>
add    $0x1,%rbp
movslq 0x4(%rsp),%rax
movslq (%rsp),%rcx
imul   %rax,%rcx
add    $0x4,%rbx
cmp    %rcx,%rbp
jl     11e0 <main+0x80>
mov    %r13,%rdi
call   1030 <fclose@plt>
mov    0x20(%r14),%rdi
lea    0xded(%rip),%rsi
call   1070 <fopen@plt>
mov    %rax,%rbx
mov    0x4(%rsp),%esi
imul   (%rsp),%esi
shl    $0x2,%esi
mov    %r15,%rdi
mov    $0x1,%edx
mov    %rax,%rcx
call   1080 <fwrite@plt>
mov    %rbx,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x8,%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 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i32
%7 = alloca i32
%8 = alloca i32
%9 = alloca float*
%10 = alloca i32*
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%11 = load i8**, i8*** %5
%12 = getelementptr inbounds i8*, i8** %11, i64 1
%13 = load i8*, i8** %12
%14 = call i32* @fopen(i8* %13, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
store i32* %14, i32** %10
%15 = load i8**, i8*** %5
%16 = getelementptr inbounds i8*, i8** %15, i64 2
%17 = load i8*, i8** %16
%18 = call i32 @sscanf(i8* %17, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %7)
%19 = load i8**, i8*** %5
%20 = getelementptr inbounds i8*, i8** %19, i64 3
%21 = load i8*, i8** %20
%22 = call i32 @sscanf(i8* %21, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %8)
%23 = load i32, i32* %7
%24 = load i32, i32* %8
%25 = mul nsw i32 %23, %24
%26 = sext i32 %25 to i64
%27 = mul i64 %26, 4
%28 = trunc i64 %27 to i32
%29 = call i64 @malloc(i32 %28)
%30 = inttoptr i64 %29 to float*
store float* %30, float** %9
store i32 0, i32* %6
br label %31
31: ; preds = %44, %2
%32 = load i32, i32* %6
%33 = load i32, i32* %7
%34 = load i32, i32* %8
%35 = mul nsw i32 %33, %34
%36 = icmp slt i32 %32, %35
br i1 %36, label %37, label %47
37: ; preds = %31
%38 = load i32*, i32** %10
%39 = load float*, float** %9
%40 = load i32, i32* %6
%41 = sext i32 %40 to i64
%42 = getelementptr inbounds float, float* %39, i64 %41
%43 = call i32 @fscanf(i32* %38, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %42)
br label %44
44: ; preds = %37
%45 = load i32, i32* %6
%46 = add nsw i32 %45, 1
store i32 %46, i32* %6
br label %31
47: ; preds = %31
%48 = load i32*, i32** %10
%49 = call i32 @fclose(i32* %48)
%50 = load i8**, i8*** %5
%51 = getelementptr inbounds i8*, i8** %50, i64 4
%52 = load i8*, i8** %51
%53 = call i32* @fopen(i8* %52, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
store i32* %53, i32** %10
%54 = load float*, float** %9
%55 = getelementptr inbounds float, float* %54, i64 0
%56 = load i32, i32* %7
%57 = load i32, i32* %8
%58 = mul nsw i32 %56, %57
%59 = sext i32 %58 to i64
%60 = mul i64 %59, 4
%61 = trunc i64 %60 to i32
%62 = load i32*, i32** %10
%63 = call i32 @fwrite(float* %55, i32 %61, i32 1, i32* %62)
%64 = load i32*, i32** %10
%65 = call i32 @fclose(i32* %64)
%66 = load i32, i32* %3
ret i32 %66
}

LLVM IR (-O2):
@.str = [2 x i8] c"r\00"
@.str.1 = [3 x i8] c"%d\00"
@.str.2 = [3 x i8] c"%f\00"
@.str.3 = [2 x i8] c"w\00"
define i32 @main(i32 %0, i8** nocapture %1) {
%3 = alloca i32
%4 = alloca i32
%5 = bitcast i32* %3 to i8*
%6 = bitcast i32* %4 to i8*
%7 = getelementptr inbounds i8*, i8** %1, i64 1
%8 = load i8*, i8** %7
%9 = tail call i32* @fopen(i8* %8, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str, i64 0, i64 0))
%10 = getelementptr inbounds i8*, i8** %1, i64 2
%11 = load i8*, i8** %10
%12 = call i32 @sscanf(i8* %11, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %3)
%13 = getelementptr inbounds i8*, i8** %1, i64 3
%14 = load i8*, i8** %13
%15 = call i32 @sscanf(i8* %14, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i32* %4)
%16 = load i32, i32* %3
%17 = load i32, i32* %4
%18 = shl i32 %16, 2
%19 = mul i32 %18, %17
%20 = call i64 @malloc(i32 %19)
%21 = inttoptr i64 %20 to float*
%22 = load i32, i32* %3
%23 = load i32, i32* %4
%24 = mul nsw i32 %23, %22
%25 = icmp sgt i32 %24, 0
br i1 %25, label %26, label %36
26: ; preds = %2, %26
%27 = phi i64 [ %30, %26 ], [ 0, %2 ]
%28 = getelementptr inbounds float, float* %21, i64 %27
%29 = call i32 @fscanf(i32* %9, i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.2, i64 0, i64 0), float* %28)
%30 = add nuw nsw i64 %27, 1
%31 = load i32, i32* %3
%32 = load i32, i32* %4
%33 = mul nsw i32 %32, %31
%34 = sext i32 %33 to i64
%35 = icmp slt i64 %30, %34
br i1 %35, label %26, label %36
36: ; preds = %26, %2
%37 = call i32 @fclose(i32* %9)
%38 = getelementptr inbounds i8*, i8** %1, i64 4
%39 = load i8*, i8** %38
%40 = call i32* @fopen(i8* %39, i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.3, i64 0, i64 0))
%41 = load i32, i32* %3
%42 = load i32, i32* %4
%43 = shl i32 %41, 2
%44 = mul i32 %43, %42
%45 = call i32 @fwrite(float* %21, i32 %44, i32 1, i32* %40)
%46 = call i32 @fclose(i32* %40)
ret i32 0
}