#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 */
typedef struct TYPE_2__ TYPE_1__;

/* Type definitions */
typedef int /*<<< orphan*/ time_t;
struct TYPE_2__ {
  scalar_t__ *sa_data;
};
struct ifreq {
  TYPE_1__ ifr_hwaddr;
  int /*<<< orphan*/ ifr_name;
};

/* Variables and functions */
int /*<<< orphan*/ AF_INET;
int /*<<< orphan*/ SIOCGIFHWADDR;
int /*<<< orphan*/ SOCK_STREAM;
scalar_t__ ioctl(int, int /*<<< orphan*/, struct ifreq *);
int /*<<< orphan*/ perror(char *);
int /*<<< orphan*/ printf(char *, ...);
int socket(int /*<<< orphan*/, int /*<<< orphan*/, int /*<<< orphan*/);
int /*<<< orphan*/ strcpy(int /*<<< orphan*/, char *);
int /*<<< orphan*/ time(int /*<<< orphan*/ *);
int main(int argc, char *argv[]) {
  struct ifreq ifreq;
  int sock;
  printf("Set-Cookie:user=helight.xu\r\n");
  printf("Content-type:text/html\r\n\r\n");
  printf("<html><head><title>MAC</title><meta http-equiv='Content-Type' "
         "content='text/html; charset=utf-8'/></head>");
  printf("<body><div width=900px><div align=center><h1>MAC "
         "ADDRESS</h1></div><hr> <div>\n");
  if ((sock = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
    perror("socket");
    return 2;
  }
  strcpy(ifreq.ifr_name, "eth0");
  if (ioctl(sock, SIOCGIFHWADDR, &ifreq) < 0) {
    perror("ioctl");
    return 3;
  }
  printf("The MAC of eth0: %02x:%02x:%02x:%02x:%02x:%02x<br>\n",
         (unsigned char)ifreq.ifr_hwaddr.sa_data[0],
         (unsigned char)ifreq.ifr_hwaddr.sa_data[1],
         (unsigned char)ifreq.ifr_hwaddr.sa_data[2],
         (unsigned char)ifreq.ifr_hwaddr.sa_data[3],
         (unsigned char)ifreq.ifr_hwaddr.sa_data[4],
         (unsigned char)ifreq.ifr_hwaddr.sa_data[5]);
  time_t the_time;
  the_time = time((time_t *)0);
  printf("The time is %ld\n", the_time);
  printf("</div><hr></div></body></html>\n");
  return 0;
}


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)
lea    0xe83(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe92(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xefb(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
mov    0x2e33(%rip),%rax
mov    (%rax),%edi
mov    0x2e12(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1080 <socket@plt>
mov    %eax,-0x24(%rbp)
cmp    $0x0,%eax
jge    11eb <main+0x8b>
lea    0xf17(%rip),%rdi
call   1070 <perror@plt>
movl   $0x2,-0x4(%rbp)
jmp    12b7 <main+0x157>
mov    -0x18(%rbp),%edi
lea    0xf03(%rip),%rsi
call   1030 <strcpy@plt>
mov    -0x24(%rbp),%edi
mov    0x2dd4(%rip),%rax
mov    (%rax),%esi
lea    -0x20(%rbp),%rdx
call   1050 <ioctl@plt>
cmp    $0x0,%rax
jge    1231 <main+0xd1>
lea    0xedd(%rip),%rdi
call   1070 <perror@plt>
movl   $0x3,-0x4(%rbp)
jmp    12b7 <main+0x157>
mov    -0x20(%rbp),%rax
mov    (%rax),%rax
movzbl %al,%esi
mov    -0x20(%rbp),%rax
mov    0x8(%rax),%rax
movzbl %al,%edx
mov    -0x20(%rbp),%rax
mov    0x10(%rax),%rax
movzbl %al,%ecx
mov    -0x20(%rbp),%rax
mov    0x18(%rax),%rax
movzbl %al,%r8d
mov    -0x20(%rbp),%rax
mov    0x20(%rax),%rax
movzbl %al,%r9d
mov    -0x20(%rbp),%rax
mov    0x28(%rax),%rax
movzbl %al,%eax
lea    0xe88(%rip),%rdi
mov    %eax,(%rsp)
mov    $0x0,%al
call   1040 <printf@plt>
xor    %eax,%eax
mov    %eax,%edi
call   1060 <time@plt>
mov    %eax,-0x28(%rbp)
mov    -0x28(%rbp),%esi
lea    0xe9c(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
lea    0xe9f(%rip),%rdi
mov    $0x0,%al
call   1040 <printf@plt>
movl   $0x0,-0x4(%rbp)
mov    -0x4(%rbp),%eax
add    $0x30,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<main>:
push   %rbx
sub    $0x20,%rsp
lea    0xf45(%rip),%rdi
call   1040 <puts@plt>
lea    0xf55(%rip),%rdi
call   1040 <puts@plt>
lea    0xe6c(%rip),%rdi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf55(%rip),%rdi
call   1040 <puts@plt>
mov    0x2e3a(%rip),%rax
mov    (%rax),%edi
mov    0x2e19(%rip),%rax
mov    (%rax),%esi
xor    %edx,%edx
call   1090 <socket@plt>
test   %eax,%eax
js     124c <main+0xdc>
mov    %eax,%ebx
lea    0xea0(%rip),%rsi
call   1030 <strcpy@plt>
mov    0x2dfb(%rip),%rax
mov    (%rax),%esi
lea    0x10(%rsp),%rdx
mov    %ebx,%edi
call   1060 <ioctl@plt>
test   %rax,%rax
js     125f <main+0xef>
mov    0x10(%rsp),%rax
movzbl (%rax),%esi
movzbl 0x8(%rax),%edx
movzbl 0x10(%rax),%ecx
movzbl 0x18(%rax),%r8d
movzbl 0x20(%rax),%r9d
movzbl 0x28(%rax),%eax
mov    %eax,(%rsp)
lea    0xe64(%rip),%rdi
xor    %ebx,%ebx
xor    %eax,%eax
call   1050 <printf@plt>
xor    %edi,%edi
call   1070 <time@plt>
lea    0xe81(%rip),%rdi
mov    %eax,%esi
xor    %eax,%eax
call   1050 <printf@plt>
lea    0xf06(%rip),%rdi
call   1040 <puts@plt>
mov    %ebx,%eax
add    $0x20,%rsp
pop    %rbx
ret
lea    0xe17(%rip),%rdi
call   1080 <perror@plt>
mov    $0x2,%ebx
jmp    1244 <main+0xd4>
lea    0xe10(%rip),%rdi
call   1080 <perror@plt>
mov    $0x3,%ebx
jmp    1244 <main+0xd4>

LLVM IR (-O0):
%struct.ifreq = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i64* }
@.str = [29 x i8] c"Set-Cookie:user=helight.xu\0D\0A\00"
@.str.1 = [27 x i8] c"Content-type:text/html\0D\0A\0D\0A\00"
@.str.2 = [106 x i8] c"<html><head><title>MAC</title><meta http-equiv='Content-Type' content='text/html; charset=utf-8'/></head>\00"
@.str.3 = [79 x i8] c"<body><div width=900px><div align=center><h1>MAC ADDRESS</h1></div><hr> <div>\0A\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.4 = [7 x i8] c"socket\00"
@.str.5 = [5 x i8] c"eth0\00"
@SIOCGIFHWADDR = global i32 0
@.str.6 = [6 x i8] c"ioctl\00"
@.str.7 = [52 x i8] c"The MAC of eth0: %02x:%02x:%02x:%02x:%02x:%02x<br>\0A\00"
@.str.8 = [17 x i8] c"The time is %ld\0A\00"
@.str.9 = [32 x i8] c"</div><hr></div></body></html>\0A\00"
define i32 @main(i32 %0, i8** %1) {
%3 = alloca i32
%4 = alloca i32
%5 = alloca i8**
%6 = alloca %struct.ifreq
%7 = alloca i32
%8 = alloca i32
store i32 0, i32* %3
store i32 %0, i32* %4
store i8** %1, i8*** %5
%9 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([29 x i8], [29 x i8]* @.str, i64 0, i64 0))
%10 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([27 x i8], [27 x i8]* @.str.1, i64 0, i64 0))
%11 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([106 x i8], [106 x i8]* @.str.2, i64 0, i64 0))
%12 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([79 x i8], [79 x i8]* @.str.3, i64 0, i64 0))
%13 = load i32, i32* @AF_INET
%14 = load i32, i32* @SOCK_STREAM
%15 = call i32 @socket(i32 %13, i32 %14, i32 0)
store i32 %15, i32* %7
%16 = icmp slt i32 %15, 0
br i1 %16, label %17, label %19
17: ; preds = %2
%18 = call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
store i32 2, i32* %3
br label %77
19: ; preds = %2
%20 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %6, i32 0, i32 1
%21 = load i32, i32* %20
%22 = call i32 @strcpy(i32 %21, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%23 = load i32, i32* %7
%24 = load i32, i32* @SIOCGIFHWADDR
%25 = call i64 @ioctl(i32 %23, i32 %24, %struct.ifreq* %6)
%26 = icmp slt i64 %25, 0
br i1 %26, label %27, label %29
27: ; preds = %19
%28 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
store i32 3, i32* %3
br label %77
29: ; preds = %19
%30 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %6, i32 0, i32 0
%31 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %30, i32 0, i32 0
%32 = load i64*, i64** %31
%33 = getelementptr inbounds i64, i64* %32, i64 0
%34 = load i64, i64* %33
%35 = trunc i64 %34 to i8
%36 = zext i8 %35 to i32
%37 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %6, i32 0, i32 0
%38 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %37, i32 0, i32 0
%39 = load i64*, i64** %38
%40 = getelementptr inbounds i64, i64* %39, i64 1
%41 = load i64, i64* %40
%42 = trunc i64 %41 to i8
%43 = zext i8 %42 to i32
%44 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %6, i32 0, i32 0
%45 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %44, i32 0, i32 0
%46 = load i64*, i64** %45
%47 = getelementptr inbounds i64, i64* %46, i64 2
%48 = load i64, i64* %47
%49 = trunc i64 %48 to i8
%50 = zext i8 %49 to i32
%51 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %6, i32 0, i32 0
%52 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %51, i32 0, i32 0
%53 = load i64*, i64** %52
%54 = getelementptr inbounds i64, i64* %53, i64 3
%55 = load i64, i64* %54
%56 = trunc i64 %55 to i8
%57 = zext i8 %56 to i32
%58 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %6, i32 0, i32 0
%59 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %58, i32 0, i32 0
%60 = load i64*, i64** %59
%61 = getelementptr inbounds i64, i64* %60, i64 4
%62 = load i64, i64* %61
%63 = trunc i64 %62 to i8
%64 = zext i8 %63 to i32
%65 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %6, i32 0, i32 0
%66 = getelementptr inbounds %struct.TYPE_2__, %struct.TYPE_2__* %65, i32 0, i32 0
%67 = load i64*, i64** %66
%68 = getelementptr inbounds i64, i64* %67, i64 5
%69 = load i64, i64* %68
%70 = trunc i64 %69 to i8
%71 = zext i8 %70 to i32
%72 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i32 %36, i32 %43, i32 %50, i32 %57, i32 %64, i32 %71)
%73 = call i32 @time(i32* null)
store i32 %73, i32* %8
%74 = load i32, i32* %8
%75 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %74)
%76 = call i32 (i8*, ...) @printf(i8* getelementptr inbounds ([32 x i8], [32 x i8]* @.str.9, i64 0, i64 0))
store i32 0, i32* %3
br label %77
77: ; preds = %29, %27, %17
%78 = load i32, i32* %3
ret i32 %78
}

LLVM IR (-O2):
%struct.ifreq = type { %struct.TYPE_2__, i32 }
%struct.TYPE_2__ = type { i64* }
@.str.2 = [106 x i8] c"<html><head><title>MAC</title><meta http-equiv='Content-Type' content='text/html; charset=utf-8'/></head>\00"
@AF_INET = global i32 0
@SOCK_STREAM = global i32 0
@.str.4 = [7 x i8] c"socket\00"
@.str.5 = [5 x i8] c"eth0\00"
@SIOCGIFHWADDR = global i32 0
@.str.6 = [6 x i8] c"ioctl\00"
@.str.7 = [52 x i8] c"The MAC of eth0: %02x:%02x:%02x:%02x:%02x:%02x<br>\0A\00"
@.str.8 = [17 x i8] c"The time is %ld\0A\00"
@str = [28 x i8] c"Set-Cookie:user=helight.xu\0D\00"
@str.10 = [26 x i8] c"Content-type:text/html\0D\0A\0D\00"
@str.11 = [78 x i8] c"<body><div width=900px><div align=center><h1>MAC ADDRESS</h1></div><hr> <div>\00"
@str.12 = [31 x i8] c"</div><hr></div></body></html>\00"
define i32 @main(i32 %0, i8** nocapture readnone %1) {
%3 = alloca %struct.ifreq
%4 = bitcast %struct.ifreq* %3 to i8*
%5 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([28 x i8], [28 x i8]* @str, i64 0, i64 0))
%6 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([26 x i8], [26 x i8]* @str.10, i64 0, i64 0))
%7 = tail call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([106 x i8], [106 x i8]* @.str.2, i64 0, i64 0))
%8 = tail call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([78 x i8], [78 x i8]* @str.11, i64 0, i64 0))
%9 = load i32, i32* @AF_INET
%10 = load i32, i32* @SOCK_STREAM
%11 = tail call i32 @socket(i32 %9, i32 %10, i32 0)
%12 = icmp slt i32 %11, 0
br i1 %12, label %13, label %15
13: ; preds = %2
%14 = tail call i32 @perror(i8* getelementptr inbounds ([7 x i8], [7 x i8]* @.str.4, i64 0, i64 0))
br label %52
15: ; preds = %2
%16 = tail call i32 @strcpy(i32 undef, i8* getelementptr inbounds ([5 x i8], [5 x i8]* @.str.5, i64 0, i64 0))
%17 = load i32, i32* @SIOCGIFHWADDR
%18 = call i64 @ioctl(i32 %11, i32 %17, %struct.ifreq* %3)
%19 = icmp slt i64 %18, 0
br i1 %19, label %20, label %22
20: ; preds = %15
%21 = call i32 @perror(i8* getelementptr inbounds ([6 x i8], [6 x i8]* @.str.6, i64 0, i64 0))
br label %52
22: ; preds = %15
%23 = getelementptr inbounds %struct.ifreq, %struct.ifreq* %3, i64 0, i32 0, i32 0
%24 = load i64*, i64** %23
%25 = load i64, i64* %24
%26 = trunc i64 %25 to i32
%27 = and i32 %26, 255
%28 = getelementptr inbounds i64, i64* %24, i64 1
%29 = load i64, i64* %28
%30 = trunc i64 %29 to i32
%31 = and i32 %30, 255
%32 = getelementptr inbounds i64, i64* %24, i64 2
%33 = load i64, i64* %32
%34 = trunc i64 %33 to i32
%35 = and i32 %34, 255
%36 = getelementptr inbounds i64, i64* %24, i64 3
%37 = load i64, i64* %36
%38 = trunc i64 %37 to i32
%39 = and i32 %38, 255
%40 = getelementptr inbounds i64, i64* %24, i64 4
%41 = load i64, i64* %40
%42 = trunc i64 %41 to i32
%43 = and i32 %42, 255
%44 = getelementptr inbounds i64, i64* %24, i64 5
%45 = load i64, i64* %44
%46 = trunc i64 %45 to i32
%47 = and i32 %46, 255
%48 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([52 x i8], [52 x i8]* @.str.7, i64 0, i64 0), i32 %27, i32 %31, i32 %35, i32 %39, i32 %43, i32 %47)
%49 = call i32 @time(i32* null)
%50 = call i32 (i8*, ...) @printf(i8* dereferenceable(1) getelementptr inbounds ([17 x i8], [17 x i8]* @.str.8, i64 0, i64 0), i32 %49)
%51 = call i32 @puts(i8* dereferenceable(1) getelementptr inbounds ([31 x i8], [31 x i8]* @str.12, i64 0, i64 0))
br label %52
52: ; preds = %22, %20, %13
%53 = phi i32 [ 2, %13 ], [ 3, %20 ], [ 0, %22 ]
ret i32 %53
}