#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*/ exit(int);
int /*<<< orphan*/ fclose(int /*<<< orphan*/ *);
int /*<<< orphan*/ fgets(char *, int, int /*<<< orphan*/);
int /*<<< orphan*/ *fopen(char *, char *);
int /*<<< orphan*/ fprintf(int /*<<< orphan*/ *, char *, ...);
int /*<<< orphan*/ printf(char *, ...);
int /*<<< orphan*/ scanf(char *, unsigned int *);
int /*<<< orphan*/ stderr;
int /*<<< orphan*/ stdin;
int main() {
  unsigned i, n;
  char name[80];
  unsigned mark;
  FILE *fout;
  if (!(fout = fopen("stinfo.txt", "a"))) {
    fprintf(stderr, "File could not be opened!\n");
    exit(5);
  }
  printf("Number of Students? ");
  scanf(" %u%*c", &n);
  for (i = 0; i < n; ++i) {
    printf("\nStudent %u\n", i + 1);
    printf("Name  : ");
    fgets(name, 80, stdin);
    printf("Marks : ");
    scanf(" %u%*c", &mark);
    fprintf(fout, "%s%u\n", name, mark);
  }
  fclose(fout);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x70,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe7a(%rip),%rdi
lea    0xe7e(%rip),%rsi
call   1080 <fopen@plt>
mov    %rax,-0x70(%rbp)
cmp    $0x0,%rax
jne    11c2 <main+0x52>
mov    0x2e31(%rip),%rax
movslq (%rax),%rdi
lea    0xe5c(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    $0x5,%edi
call   1090 <exit@plt>
lea    0xe5f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe66(%rip),%rdi
lea    -0xc(%rbp),%rsi
call   1070 <scanf@plt>
movl   $0x0,-0x8(%rbp)
mov    -0x8(%rbp),%eax
cmp    -0xc(%rbp),%eax
jae    1271 <main+0x101>
mov    -0x8(%rbp),%esi
add    $0x1,%esi
lea    0xe44(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe43(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    -0x60(%rbp),%rdi
mov    0x2dc8(%rip),%rax
mov    (%rax),%edx
mov    $0x50,%esi
call   1050 <fgets@plt>
lea    0xe27(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xdfc(%rip),%rdi
lea    -0x64(%rbp),%rsi
call   1070 <scanf@plt>
mov    -0x70(%rbp),%rdi
lea    -0x60(%rbp),%rdx
mov    -0x64(%rbp),%ecx
lea    0xe07(%rip),%rsi
mov    $0x0,%al
call   1060 <fprintf@plt>
mov    -0x8(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x8(%rbp)
jmp    11e7 <main+0x77>
mov    -0x70(%rbp),%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x70,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r13
push   %r12
push   %rbx
sub    $0x68,%rsp
lea    0xe6b(%rip),%rdi
lea    0xe6f(%rip),%rsi
call   1080 <fopen@plt>
test   %rax,%rax
je     1286 <main+0x106>
mov    %rax,%r12
lea    0xe74(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe7b(%rip),%rdi
lea    0x8(%rsp),%rsi
call   1070 <scanf@plt>
cmpl   $0x0,0x8(%rsp)
je     126d <main+0xed>
lea    0x10(%rsp),%rbx
lea    0xe5a(%rip),%rbp
lea    0xc(%rsp),%r14
lea    0xe74(%rip),%r15
xor    %r13d,%r13d
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
add    $0x1,%r13d
lea    0xe39(%rip),%rdi
mov    %r13d,%esi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xe35(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    0x2dbe(%rip),%rax
mov    (%rax),%edx
mov    %rbx,%rdi
mov    $0x50,%esi
call   1050 <fgets@plt>
lea    0xe1a(%rip),%rdi
xor    %eax,%eax
call   1040 <printf@plt>
mov    %rbp,%rdi
mov    %r14,%rsi
call   1070 <scanf@plt>
mov    0xc(%rsp),%ecx
mov    %r12,%rdi
mov    %r15,%rsi
mov    %rbx,%rdx
xor    %eax,%eax
call   1060 <fprintf@plt>
cmp    0x8(%rsp),%r13d
jb     1200 <main+0x80>
mov    %r12,%rdi
call   1030 <fclose@plt>
xor    %eax,%eax
add    $0x68,%rsp
pop    %rbx
pop    %r12
pop    %r13
pop    %r14
pop    %r15
pop    %rbp
ret
mov    0x2d4b(%rip),%rax
movslq (%rax),%rcx
lea    0xd76(%rip),%rdi
mov    $0x1a,%esi
mov    $0x1,%edx
call   10a0 <fwrite@plt>
mov    $0x5,%edi
call   1090 <exit@plt>

LLVM IR (-O0):
@.str = [11 x i8] c"stinfo.txt\00"
@.str.1 = [2 x i8] c"a\00"
@stderr = global i32 0
@.str.2 = [27 x i8] c"File could not be opened!\0A\00"
@.str.3 = [21 x i8] c"Number of Students? \00"
@.str.4 = [7 x i8] c" %u%*c\00"
@.str.5 = [13 x i8] c"\0AStudent %u\0A\00"
@.str.6 = [9 x i8] c"Name : \00"
@stdin = global i32 0
@.str.7 = [9 x i8] c"Marks : \00"
@.str.8 = [6 x i8] c"%s%u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca [80 x i8]
%5 = alloca i32
%6 = alloca i32*
store i32 0, i32* %1
%7 = call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
store i32* %7, i32** %6
%8 = icmp ne i32* %7, null
br i1 %8, label %15, label %9
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i32*
%13 = call i32 (i32*, i8*, ...) @fprintf(i32* %12, i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0))
%14 = call i32 @exit(i32 5)
unreachable
15: ; preds = %0
%16 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %3)
store i32 0, i32* %2
br label %18
18: ; preds = %36, %15
%19 = load i32, i32* %2
%20 = load i32, i32* %3
%21 = icmp ult i32 %19, %20
br i1 %21, label %22, label %39
22: ; preds = %18
%23 = load i32, i32* %2
%24 = add i32 %23, 1
%25 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %24)
%26 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%27 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%28 = load i32, i32* @stdin
%29 = call i32 @fgets(i8* %27, i32 80, i32 %28)
%30 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%31 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %5)
%32 = load i32*, i32** %6
%33 = getelementptr inbounds [80 x i8], [80 x i8]* %4, i64 0, i64 0
%34 = load i32, i32* %5
%35 = call i32 (i32*, i8*, ...) @fprintf(i32* %32, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* %33, i32 %34)
br label %36
36: ; preds = %22
%37 = load i32, i32* %2
%38 = add i32 %37, 1
store i32 %38, i32* %2
br label %18
39: ; preds = %18
%40 = load i32*, i32** %6
%41 = call i32 @fclose(i32* %40)
ret i32 0
}

LLVM IR (-O2):
@.str = [11 x i8] c"stinfo.txt\00"
@.str.1 = [2 x i8] c"a\00"
@stderr = global i32 0
@.str.2 = [27 x i8] c"File could not be opened!\0A\00"
@.str.3 = [21 x i8] c"Number of Students? \00"
@.str.4 = [7 x i8] c" %u%*c\00"
@.str.5 = [13 x i8] c"\0AStudent %u\0A\00"
@.str.6 = [9 x i8] c"Name : \00"
@stdin = global i32 0
@.str.7 = [9 x i8] c"Marks : \00"
@.str.8 = [6 x i8] c"%s%u\0A\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca [80 x i8]
%3 = alloca i32
%4 = bitcast i32* %1 to i8*
%5 = getelementptr inbounds [80 x i8], [80 x i8]* %2, i64 0, i64 0
%6 = bitcast i32* %3 to i8*
%7 = tail call i32* @fopen(i8* getelementptr inbounds ([11 x i8], [11 x i8]* @.str, i64 0, i64 0), i8* getelementptr inbounds ([2 x i8], [2 x i8]* @.str.1, i64 0, i64 0))
%8 = icmp eq i32* %7, null
br i1 %8, label %9, label %15
9: ; preds = %0
%10 = load i32, i32* @stderr
%11 = sext i32 %10 to i64
%12 = inttoptr i64 %11 to i32*
%13 = tail call i64 @fwrite(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.2, i64 0, i64 0), i64 26, i64 1, i32* %12)
%14 = tail call i32 @exit(i32 5)
unreachable
15: ; preds = %0
%16 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([21 x i8], [21 x i8]* @.str.3, i64 0, i64 0))
%17 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %1)
%18 = load i32, i32* %1
%19 = icmp eq i32 %18, 0
br i1 %19, label %33, label %20
20: ; preds = %15, %20
%21 = phi i32 [ %22, %20 ], [ 0, %15 ]
%22 = add nuw i32 %21, 1
%23 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([13 x i8], [13 x i8]* @.str.5, i64 0, i64 0), i32 %22)
%24 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.6, i64 0, i64 0))
%25 = load i32, i32* @stdin
%26 = call i32 @fgets(i8* %5, i32 80, i32 %25)
%27 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([9 x i8], [9 x i8]* @.str.7, i64 0, i64 0))
%28 = call i32 @scanf(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0), i32* %3)
%29 = load i32, i32* %3
%30 = call i32 (i32*, i8*, ...) @fprintf(i32* %7, i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.8, i64 0, i64 0), i8* %5, i32 %29)
%31 = load i32, i32* %1
%32 = icmp ult i32 %22, %31
br i1 %32, label %20, label %33
33: ; preds = %20, %15
%34 = call i32 @fclose(i32* %7)
ret i32 0
}