#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*/ printf(char *, char *, ...);
int /*<<< orphan*/ strcpy(char *, char *);
int main(void) {
  struct person_name {
    char first[20 + 1];
    char middle_initial;
    char last[20 + 1];
  };
  struct student {
    struct person_name name;
    int id, age;
    char sex;
  } student1, student2;
  strcpy(student1.name.first, "karthik");
  printf("first name: %s\n", student1.name.first);
  printf("compiled on %s at %s on %s\n", "Mar 17 2022", "22:43:03",
         "/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/"
         "2022-01-22/02-19-57/repos/kar7hik/c_programming/refs/heads/master/"
         "C16/struct_example.c");
  return 0;
}


x86 assembly (clang, -O0):
<main>:
push   %rbp
mov    %rsp,%rbp
sub    $0x80,%rsp
movl   $0x0,-0x4(%rbp)
lea    -0x40(%rbp),%rdi
lea    0xec3(%rip),%rsi
call   1030 <strcpy@plt>
lea    -0x40(%rbp),%rsi
lea    0xebb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xebd(%rip),%rdi
lea    0xed2(%rip),%rsi
lea    0xed7(%rip),%rdx
lea    0xed9(%rip),%rcx
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x80,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x40,%rsp
lea    0xed4(%rip),%rsi
lea    0x8(%rsp),%rbx
mov    %rbx,%rdi
call   1030 <strcpy@plt>
lea    0xec8(%rip),%rdi
mov    %rbx,%rsi
xor    %eax,%eax
call   1040 <printf@plt>
lea    0xec7(%rip),%rdi
lea    0xedc(%rip),%rsi
lea    0xee1(%rip),%rdx
lea    0xee3(%rip),%rcx
xor    %eax,%eax
call   1040 <printf@plt>
xor    %eax,%eax
add    $0x40,%rsp
pop    %rbx
ret

LLVM IR (-O0):
%struct.student = type { %struct.person_name, i32, i32, i8 }
%struct.person_name = type { [21 x i8], i8, [21 x i8] }
@.str = [8 x i8] c"karthik\00"
@.str.1 = [16 x i8] c"first name: %s\0A\00"
@.str.2 = [28 x i8] c"compiled on %s at %s on %s\0A\00"
@.str.3 = [12 x i8] c"Mar 17 2022\00"
@.str.4 = [9 x i8] c"22:43:03\00"
@.str.5 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kar7hik/c_programming/refs/heads/master/C16/struct_example.c\00"
define i32 @main() {
%1 = alloca i32
%2 = alloca %struct.student
%3 = alloca %struct.student
store i32 0, i32* %1
%4 = getelementptr inbounds %struct.student, %struct.student* %2, i32 0, i32 0
%5 = getelementptr inbounds %struct.person_name, %struct.person_name* %4, i32 0, i32 0
%6 = getelementptr inbounds [21 x i8], [21 x i8]* %5, i64 0, i64 0
%7 = call i32 @strcpy(i8* %6, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%8 = getelementptr inbounds %struct.student, %struct.student* %2, i32 0, i32 0
%9 = getelementptr inbounds %struct.person_name, %struct.person_name* %8, i32 0, i32 0
%10 = getelementptr inbounds [21 x i8], [21 x i8]* %9, i64 0, i64 0
%11 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %10)
%12 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}

LLVM IR (-O2):
%struct.student = type { %struct.person_name, i32, i32, i8 }
%struct.person_name = type { [21 x i8], i8, [21 x i8] }
@.str = [8 x i8] c"karthik\00"
@.str.1 = [16 x i8] c"first name: %s\0A\00"
@.str.2 = [28 x i8] c"compiled on %s at %s on %s\0A\00"
@.str.3 = [12 x i8] c"Mar 17 2022\00"
@.str.4 = [9 x i8] c"22:43:03\00"
@.str.5 = [151 x i8] c"/scratch/repos/new/home/jordi_armengol_estape/c-scraper/outputs/2022-01-22/02-19-57/repos/kar7hik/c_programming/refs/heads/master/C16/struct_example.c\00"
define i32 @main() {
%1 = alloca %struct.student
%2 = getelementptr inbounds %struct.student, %struct.student* %1, i64 0, i32 0, i32 0, i64 0
%3 = call i32 @strcpy(i8* %2, i8* getelementptr inbounds ([8 x i8], [8 x i8]* @.str, i64 0, i64 0))
%4 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([16 x i8], [16 x i8]* @.str.1, i64 0, i64 0), i8* %2)
%5 = call i32 (i8*, i8*, ...) @printf(i8* getelementptr inbounds ([28 x i8], [28 x i8]* @.str.2, i64 0, i64 0), i8* getelementptr inbounds ([12 x i8], [12 x i8]* @.str.3, i64 0, i64 0), i8* getelementptr inbounds ([9 x i8], [9 x i8]* @.str.4, i64 0, i64 0), i8* getelementptr inbounds ([151 x i8], [151 x i8]* @.str.5, i64 0, i64 0))
ret i32 0
}