#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*/ time_t;
struct tm {
  int dummy;
};

/* Variables and functions */
struct tm *gmtime(int /*<<< orphan*/ *);
int /*<<< orphan*/ sprintf(char *, char *, char *, char *, char *);
int /*<<< orphan*/ strftime(char *, int, char *, struct tm *);
int /*<<< orphan*/ system(char *);
void gate_address_ipv4(char *interface_id, char *dst_addr,
                       time_t time_expiration) {
  char time_string[256];
  struct tm *tm_info = gmtime(&time_expiration);
  strftime(time_string, 26, "%Y-%m-%dT%H:%M:%S", tm_info);
  char output[256];
  sprintf(output,
          "iptables -I FORWARD -i %s -d %s -m time --datestop %s -j ACCEPT\n",
          interface_id, dst_addr, time_string);
  system(output);
}


x86 assembly (clang, -O0):
<gate_address_ipv4>:
push   %rbp
mov    %rsp,%rbp
sub    $0x230,%rsp
mov    %rdi,-0x8(%rbp)
mov    %rsi,-0x10(%rbp)
mov    %edx,-0x14(%rbp)
lea    -0x14(%rbp),%rdi
call   1050 <gmtime@plt>
mov    %rax,-0x128(%rbp)
lea    -0x120(%rbp),%rdi
mov    -0x128(%rbp),%rcx
mov    $0x1a,%esi
lea    0xe80(%rip),%rdx
call   1040 <strftime@plt>
lea    -0x230(%rbp),%rdi
mov    -0x8(%rbp),%rdx
mov    -0x10(%rbp),%rcx
lea    -0x120(%rbp),%r8
lea    0xe70(%rip),%rsi
call   1060 <sprintf@plt>
lea    -0x230(%rbp),%rdi
call   1030 <system@plt>
add    $0x230,%rsp
pop    %rbp
ret

x86 assembly (clang, -O2):
<gate_address_ipv4>:
push   %r15
push   %r14
push   %r12
push   %rbx
sub    $0x218,%rsp
mov    %rsi,%r14
mov    %rdi,%r12
mov    %edx,0xc(%rsp)
lea    0xc(%rsp),%rdi
call   1050 <gmtime@plt>
lea    0xe97(%rip),%rdx
lea    0x110(%rsp),%r15
mov    %r15,%rdi
mov    $0x1a,%esi
mov    %rax,%rcx
call   1040 <strftime@plt>
lea    0xe8a(%rip),%rsi
lea    0x10(%rsp),%rbx
mov    %rbx,%rdi
mov    %r12,%rdx
mov    %r14,%rcx
mov    %r15,%r8
call   1060 <sprintf@plt>
mov    %rbx,%rdi
call   1030 <system@plt>
add    $0x218,%rsp
pop    %rbx
pop    %r12
pop    %r14
pop    %r15
ret

LLVM IR (-O0):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%dT%H:%M:%S\00"
@.str.1 = [65 x i8] c"iptables -I FORWARD -i %s -d %s -m time --datestop %s -j ACCEPT\0A\00"
define void @gate_address_ipv4(i8* %0, i8* %1, i32 %2) {
%4 = alloca i8*
%5 = alloca i8*
%6 = alloca i32
%7 = alloca [256 x i8]
%8 = alloca %struct.tm*
%9 = alloca [256 x i8]
store i8* %0, i8** %4
store i8* %1, i8** %5
store i32 %2, i32* %6
%10 = call %struct.tm* @gmtime(i32* %6)
store %struct.tm* %10, %struct.tm** %8
%11 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%12 = load %struct.tm*, %struct.tm** %8
%13 = call i32 @strftime(i8* %11, i32 26, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %12)
%14 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%15 = load i8*, i8** %4
%16 = load i8*, i8** %5
%17 = getelementptr inbounds [256 x i8], [256 x i8]* %7, i64 0, i64 0
%18 = call i32 @sprintf(i8* %14, i8* getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8* %15, i8* %16, i8* %17)
%19 = getelementptr inbounds [256 x i8], [256 x i8]* %9, i64 0, i64 0
%20 = call i32 @system(i8* %19)
ret void
}

LLVM IR (-O2):
%struct.tm = type { i32 }
@.str = [18 x i8] c"%Y-%m-%dT%H:%M:%S\00"
@.str.1 = [65 x i8] c"iptables -I FORWARD -i %s -d %s -m time --datestop %s -j ACCEPT\0A\00"
define void @gate_address_ipv4(i8* %0, i8* %1, i32 %2) {
%4 = alloca i32
%5 = alloca [256 x i8]
%6 = alloca [256 x i8]
store i32 %2, i32* %4
%7 = getelementptr inbounds [256 x i8], [256 x i8]* %5, i64 0, i64 0
%8 = call %struct.tm* @gmtime(i32* %4)
%9 = call i32 @strftime(i8* %7, i32 26, i8* getelementptr inbounds ([18 x i8], [18 x i8]* @.str, i64 0, i64 0), %struct.tm* %8)
%10 = getelementptr inbounds [256 x i8], [256 x i8]* %6, i64 0, i64 0
%11 = call i32 @sprintf(i8* %10, i8* dereferenceable(1) getelementptr inbounds ([65 x i8], [65 x i8]* @.str.1, i64 0, i64 0), i8* %0, i8* %1, i8* %7)
%12 = call i32 @system(i8* %10)
ret void
}