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

/* Variables and functions */
int /*<<< orphan*/ EXIT_FAILURE;
int EXIT_SUCCESS;
int /*<<< orphan*/ check_intInput(int *);
int /*<<< orphan*/ exit(int /*<<< orphan*/);
int /*<<< orphan*/ fill_array(int *, int);
int /*<<< orphan*/ printf(char *);
int /*<<< orphan*/ vector_scalar_multiply(int *, int, int);
int main() {
  int dimension;
  printf("Enter dimension: ");
  check_intInput(&dimension);
  if (dimension <= 0) {
    printf("dimension > 0 !");
    exit(EXIT_FAILURE);
  }
  int scalar;
  printf("Enter scalar: ");
  check_intInput(&scalar);
  int vector[dimension];
  printf("Enter vector members : ");
  fill_array(vector, dimension);
  vector_scalar_multiply(vector, dimension, scalar);
  return (EXIT_SUCCESS);
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x30,%rsp
movl   $0x0,-0x4(%rbp)
lea    0xe9a(%rip),%rdi
call   1040 <printf@plt>
lea    -0x8(%rbp),%rdi
call   1030 <check_intInput@plt>
cmpl   $0x0,-0x8(%rbp)
jg     1198 <main+0x48>
lea    0xe8d(%rip),%rdi
call   1040 <printf@plt>
mov    0x2e4f(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>
lea    0xe83(%rip),%rdi
call   1040 <printf@plt>
lea    -0xc(%rbp),%rdi
call   1030 <check_intInput@plt>
mov    -0x8(%rbp),%eax
mov    %rsp,%rcx
mov    %rcx,-0x18(%rbp)
lea    0xf(,%rax,4),%rdx
and    $0xfffffffffffffff0,%rdx
mov    %rsp,%rcx
sub    %rdx,%rcx
mov    %rcx,-0x28(%rbp)
mov    %rcx,%rsp
mov    %rax,-0x20(%rbp)
lea    0xe56(%rip),%rdi
call   1040 <printf@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
call   1050 <fill_array@plt>
mov    -0x28(%rbp),%rdi
mov    -0x8(%rbp),%esi
mov    -0xc(%rbp),%edx
call   1070 <vector_scalar_multiply@plt>
mov    0x2dd6(%rip),%rax
mov    (%rax),%eax
mov    %eax,-0x4(%rbp)
mov    -0x18(%rbp),%rax
mov    %rax,%rsp
mov    -0x4(%rbp),%eax
mov    %rbp,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbp
mov    %rsp,%rbp
push   %r14
push   %rbx
sub    $0x10,%rsp
lea    0xe9e(%rip),%rdi
call   1040 <printf@plt>
lea    -0x14(%rbp),%rdi
call   1030 <check_intInput@plt>
cmpl   $0x0,-0x14(%rbp)
jle    11e0 <main+0x90>
lea    0xea5(%rip),%rdi
call   1040 <printf@plt>
lea    -0x18(%rbp),%rdi
call   1030 <check_intInput@plt>
mov    %rsp,%r14
mov    -0x14(%rbp),%eax
mov    %rsp,%rbx
lea    0xf(,%rax,4),%rax
and    $0xfffffffffffffff0,%rax
sub    %rax,%rbx
mov    %rbx,%rsp
lea    0xe84(%rip),%rdi
call   1040 <printf@plt>
mov    -0x14(%rbp),%esi
mov    %rbx,%rdi
call   1050 <fill_array@plt>
mov    -0x14(%rbp),%esi
mov    -0x18(%rbp),%edx
mov    %rbx,%rdi
call   1070 <vector_scalar_multiply@plt>
mov    0x2e06(%rip),%rax
mov    (%rax),%eax
mov    %r14,%rsp
lea    -0x10(%rbp),%rsp
pop    %rbx
pop    %r14
pop    %rbp
ret
lea    0xe2b(%rip),%rdi
call   1040 <printf@plt>
mov    0x2ded(%rip),%rax
mov    (%rax),%edi
call   1060 <exit@plt>

LLVM IR (-O0):
@.str = [18 x i8] c"Enter dimension: \00"
@.str.1 = [16 x i8] c"dimension > 0 !\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [15 x i8] c"Enter scalar: \00"
@.str.3 = [24 x i8] c"Enter vector members : \00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = alloca i32
%4 = alloca i8*
%5 = alloca i64
store i32 0, i32* %1
%6 = call i32 @printf(i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%7 = call i32 @check_intInput(i32* %2)
%8 = load i32, i32* %2
%9 = icmp sle i32 %8, 0
br i1 %9, label %10, label %14
10: ; preds = %0
%11 = call i32 @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%12 = load i32, i32* @EXIT_FAILURE
%13 = call i32 @exit(i32 %12)
unreachable
14: ; preds = %0
%15 = call i32 @printf(i8* getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%16 = call i32 @check_intInput(i32* %3)
%17 = load i32, i32* %2
%18 = zext i32 %17 to i64
%19 = call i8* @llvm.stacksave()
store i8* %19, i8** %4
%20 = alloca i32, i64 %18
store i64 %18, i64* %5
%21 = call i32 @printf(i8* getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%22 = load i32, i32* %2
%23 = call i32 @fill_array(i32* %20, i32 %22)
%24 = load i32, i32* %2
%25 = load i32, i32* %3
%26 = call i32 @vector_scalar_multiply(i32* %20, i32 %24, i32 %25)
%27 = load i32, i32* @EXIT_SUCCESS
store i32 %27, i32* %1
%28 = load i8*, i8** %4
%29 = load i32, i32* %1
ret i32 %29
}

LLVM IR (-O2):
@.str = [18 x i8] c"Enter dimension: \00"
@.str.1 = [16 x i8] c"dimension > 0 !\00"
@EXIT_FAILURE = global i32 0
@.str.2 = [15 x i8] c"Enter scalar: \00"
@.str.3 = [24 x i8] c"Enter vector members : \00"
@EXIT_SUCCESS = global i32 0
define i32 @main() {
%1 = alloca i32
%2 = alloca i32
%3 = bitcast i32* %1 to i8*
%4 = tail call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0))
%5 = call i32 @check_intInput(i32* %1)
%6 = load i32, i32* %1
%7 = icmp slt i32 %6, 1
br i1 %7, label %8, label %12
8: ; preds = %0
%9 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0))
%10 = load i32, i32* @EXIT_FAILURE
%11 = call i32 @exit(i32 %10)
unreachable
12: ; preds = %0
%13 = bitcast i32* %2 to i8*
%14 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([15 x i8], [15 x i8]* @.str.2, i64 0, i64 0))
%15 = call i32 @check_intInput(i32* %2)
%16 = load i32, i32* %1
%17 = zext i32 %16 to i64
%18 = call i8* @llvm.stacksave()
%19 = alloca i32, i64 %17
%20 = call i32 @printf(i8* dereferenceable(1) getelementptr inbounds ([24 x i8], [24 x i8]* @.str.3, i64 0, i64 0))
%21 = load i32, i32* %1
%22 = call i32 @fill_array(i32* %19, i32 %21)
%23 = load i32, i32* %1
%24 = load i32, i32* %2
%25 = call i32 @vector_scalar_multiply(i32* %19, i32 %23, i32 %24)
%26 = load i32, i32* @EXIT_SUCCESS
ret i32 %26
}