#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 */
struct struct_1 {
  int dummy;
};
typedef int int32_t;

/* Variables and functions */
int /*<<< orphan*/ free(char *);
int /*<<< orphan*/ handle_task(int, struct struct_1 *);
char *malloc(int);
int /*<<< orphan*/ printf(char *, int);
int /*<<< orphan*/ scanf(char *, char *);
int main(int argc, char **argv) {
  char *mem = malloc(101);
  for (int32_t i = 0; i < argc - 1; i++) {
    printf("Enter Solution for task %d:", i);
    scanf("%s", mem);
    handle_task(i, (struct struct_1 *)mem);
  }
  free(mem);
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x20,%rsp
movl   $0x0,-0x4(%rbp)
mov    %edi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    $0x65,%edi
call   1060 <malloc@plt>
mov    %rax,-0x18(%rbp)
movl   $0x0,-0x1c(%rbp)
mov    -0x1c(%rbp),%eax
mov    -0x8(%rbp),%ecx
sub    $0x1,%ecx
cmp    %ecx,%eax
jge    11c5 <main+0x75>
mov    -0x1c(%rbp),%esi
lea    0xe6a(%rip),%rdi
call   1040 <printf@plt>
mov    -0x18(%rbp),%rsi
lea    0xe76(%rip),%rdi
call   1070 <scanf@plt>
mov    -0x1c(%rbp),%edi
mov    -0x18(%rbp),%rsi
call   1050 <handle_task@plt>
mov    -0x1c(%rbp),%eax
add    $0x1,%eax
mov    %eax,-0x1c(%rbp)
jmp    117b <main+0x2b>
mov    -0x18(%rbp),%rdi
call   1030 <free@plt>
xor    %eax,%eax
add    $0x20,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
push   %r15
push   %r14
push   %r12
push   %rbx
mov    %edi,%r14d
mov    $0x65,%edi
call   1060 <malloc@plt>
mov    %rax,%rbx
cmp    $0x2,%r14d
jl     11b7 <main+0x67>
add    $0xffffffff,%r14d
xor    %ebp,%ebp
lea    0xe85(%rip),%r15
lea    0xe9a(%rip),%r12
cs nopw 0x0(%rax,%rax,1)
nopl   0x0(%rax)
mov    %r15,%rdi
mov    %ebp,%esi
call   1040 <printf@plt>
mov    %r12,%rdi
mov    %rbx,%rsi
call   1070 <scanf@plt>
mov    %ebp,%edi
mov    %rbx,%rsi
call   1050 <handle_task@plt>
add    $0x1,%ebp
cmp    %ebp,%r14d
jne    1190 <main+0x40>
mov    %rbx,%rdi
call   1030 <free@plt>
xor    %eax,%eax
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
pop    %rbp
ret

LLVM IR (-O0):
%struct.struct_1 = type { i32 }
@.str = [28 x i8] c"Enter Solution for task %d:\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca i8*
%7 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%8 = call i8* @malloc(i32 101)
store i8* %8, i8** %6
store i32 0, i32* %7
br label %9
9: ; preds = %23, %2
%10 = load i32, i32* %7
%11 = load i32, i32* %4
%12 = sub nsw i32 %11, 1
%13 = icmp slt i32 %10, %12
br i1 %13, label %14, label %26
14: ; preds = %9
%15 = load i32, i32* %7
%16 = call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %15)
%17 = load i8*, i8** %6
%18 = call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %17)
%19 = load i32, i32* %7
%20 = load i8*, i8** %6
%21 = bitcast i8* %20 to %struct.struct_1*
%22 = call i32 @handle_task(i32 %19, %struct.struct_1* %21)
br label %23
23: ; preds = %14
%24 = load i32, i32* %7
%25 = add nsw i32 %24, 1
store i32 %25, i32* %7
br label %9
26: ; preds = %9
%27 = load i8*, i8** %6
%28 = call i32 @free(i8* %27)
ret i32 0
}

LLVM IR (-O2):
%struct.struct_1 = type { i32 }
@.str = [28 x i8] c"Enter Solution for task %d:\00"
@.str.1 = [3 x i8] c"%s\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = tail call dereferenceable_or_null(101) i8* @malloc(i32 101)
%4 = add i32 %0, -1
%5 = icmp sgt i32 %0, 1
br i1 %5, label %6, label %8
6: ; preds = %2
%7 = bitcast i8* %3 to %struct.struct_1*
br label %10
8: ; preds = %10, %2
%9 = tail call i32 @free(i8* %3)
ret i32 0
10: ; preds = %6, %10
%11 = phi i32 [ 0, %6 ], [ %15, %10 ]
%12 = tail call i32 @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str, i64 0, i64 0), i32 %11)
%13 = tail call i32 @scanf(i8* getelementptr inbounds ([3 x i8], [3 x i8]* @.str.1, i64 0, i64 0), i8* %3)
%14 = tail call i32 @handle_task(i32 %11, %struct.struct_1* %7)
%15 = add nuw nsw i32 %11, 1
%16 = icmp eq i32 %15, %4
br i1 %16, label %8, label %10
}